Unable to reload TableView Data in iOS App?

You've made the classic memory management mistake: You're directly accessing your ivars and it burned you.

Up vote 0 down vote favorite share g+ share fb share tw.

I find my self out of ideas trying to get this app to work. My app uses a split view to show to lists. The "Master" list should hold a list of the user's Facebook friends.

Since the app does not force you to login, if you're not logged in yet it shows "You have no friends" in the list till you've logged in. My problem is that once I've loaded all the friends and call self. TableView reloadData my program crashes some in there, and despite my best attempts at debugging it I can't find it.

The method is - (void)request:(FBRequest *)request didLoad:(id)result { if (result isKindOfClass:NSArray class && (result count > 0)) { result = result objectAtIndex:0; } switch (((Facebook *)Facebook shared). CurrentCall) { case graphUserFriends: { _friends = NSMutableArray array; NSArray *resultData = result objectForKey:@"data"; if (resultData count > 0) { for (NSUInteger i=0; I GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions.

There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-apple-darwin".

Sharedlibrary apply-load-rules all Attaching to process 48870. Catchpoint 3 (throw)Pending breakpoint 1 - "objc_exception_throw" resolved Current language: auto; currently objective-c (gdb) bt #0 0x0156ecf0 in objc_exception_throw () #1 0x013c9674 in -__NSArrayI objectAtIndex: () #2 0x00454805 in -UITableViewDataSource tableView:heightForRowAtIndexPath: () #3 0x0026427a in -UITableViewController tableView:heightForRowAtIndexPath: () #4 0x0020f548 in -UISectionRowData refreshWithSection:tableView:tableViewRowData: () #5 0x00211722 in -UITableViewRowData numberOfRows () #6 0x000c17c7 in -UITableView noteNumberOfRowsChanged () #7 0x000c12c1 in -UITableView reloadData () #8 0x0000247e in -MasterViewController request:didLoad: (self=0x6a491e0, _cmd=0x12e65, request=0x681e930, result=0x6824250) at /Users/CheckM8/Documents/Xcode 4/Projects/iPeople4/iPeople4/MasterViewController. M:46 #9 0x00009d36 in -FBRequest handleResponseData: (self=0x681e930, _cmd=0x1397a, data=0x6a76c60) at /Users/CheckM8/Documents/Xcode 4/facebook-facebook-ios-sdk-74358cd/src/FBRequest.

M:261 #10 0x0000a357 in -FBRequest connectionDidFinishLoading: (self=0x681e930, _cmd=0xade62e, connection=0x681ec40) at /Users/CheckM8/Documents/Xcode 4/facebook-facebook-ios-sdk-74358cd/src/FBRequest. M:346 #11 0x00a29a59 in ___NSURLConnectionDidFinishLoading_block_invoke_0 () #12 0x00a27e94 in __65-NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:_block_invoke_0 () #13 0x00a28eb7 in -NSURLConnectionInternalConnection invokeForDelegate: () #14 0x00a27e4f in -NSURLConnectionInternal _withConnectionAndDelegate:onlyActive: () #15 0x00a27fd5 in -NSURLConnectionInternal _withActiveConnectionAndDelegate: () #16 0x0096cf6a in _NSURLConnectionDidFinishLoading () #17 0x0398fbbd in URLConnectionClient::_clientDidFinishLoading () #18 0x03a5c5ea in URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload () #19 0x03986298 in URLConnectionClient::processEvents () #20 0x03a5c16b in non-virtual thunk to URLConnectionInstanceData::multiplexerClientPerform() () #21 0x03986137 in MultiplexerSource::perform () #22 0x013b197f in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ () #23 0x01314b73 in __CFRunLoopDoSources0 () #24 0x01314454 in __CFRunLoopRun () #25 0x01313db4 in CFRunLoopRunSpecific () #26 0x01313ccb in CFRunLoopRunInMode () #27 0x012c6879 in GSEventRunModal () #28 0x012c693e in GSEventRun () #29 0x00034a9b in UIApplicationMain () #30 0x00001d82 in main (argc=1, argv=0xbfffed64) at /Users/CheckM8/Documents/Xcode 4/Projects/iPeople4/iPeople4/main. M:16 #31 0x00001cf5 in start () ios tableview link|improve this question edited Dec 6 '11 at 15:59 asked Dec 6 '11 at 14:47Samuel Englard274.

(just an idea) – Jacky Boy Dec 6 '11 at 15:05 Tried them, but they didn't report anything – Samuel Englard Dec 6 '11 at 15:17.

You've made the classic memory management mistake: You're directly accessing your ivars and it burned you. _friends = NSMutableArray array; This is an under-retain (which will crash later), and also a possible leak if _friends had a prior value. You should always use accessors for your ivars except in dealloc and init: self.

Friends = NSMutableArray array; ... self. Friends addObject:f; EDIT: From your stacktrace, your bug is in your table view data source's tableView:heightForRowAtIndexPath:. It looks like you're reading off the end of your array.

– Samuel Englard Dec 6 '11 at 15:16 Yes you should. – Jacky Boy Dec 6 '11 at 15:24 Added it as a nonatomic and retain property but it still crashed the same. Good idea but didn't solve this problem yet, thanks!

– Samuel Englard Dec 6 '11 at 15:25 The errors above code strongly suggests that you have other memory management mistakes. You should audit your use of ivars, not just here. You should also post the actual crash.

– Rob Napier Dec 6 '11 at 15:31 OK, I'll give them a once over and get back to you. I'll post the Crash in a second. – Samuel Englard Dec 6 '11 at 15:35.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions