2011-12-06 26 views
0

私は自分のアイデアからこのアプリを動作させようとしています。私のアプリはスプリットビューを使ってリストに表示します。 「マスター」リストには、ユーザーのFacebookフレンドのリストが保持されます。あなたがまだログインしていなければ、あなたがログインするまで「あなたは友人がいません」と表示されます。私の問題は、すべての友人を連れて電話したら[self.tableView reloadData]私のプログラムがそこでクラッシュしてしまい、デバッグに苦労したにもかかわらず見つけられませんでした。この方法は、iOS AppでTableViewデータを読み込めません

- (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<[resultData count] && i < 25; i++) 
        { 
         NSDictionary *friendDictionary = [resultData objectAtIndex:i]; 
         FbFriend * f = [[[FbFriend alloc] initWithName:[friendDictionary objectForKey:@"name"] Id:[friendDictionary objectForKey:@"id"]] autorelease]; 
         [_friends addObject:f]; 
        } 
       } 
       [self.tableView reloadData]; 
       break; 
      } 
      default: 
       break; 
     } 
    } 

全体のソースコード(とXcode 4のプロジェクト)である(クラッシュ時)https://skydrive.live.com/redir.aspx?cid=04b38cdd7b38bb7f&resid=4B38CDD7B38BB7F!798&parid=4B38CDD7B38BB7F!470&authkey=!API4iVva95nZFL8

コンソールからダウンロードすることができます。

GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 15 16:03:10 UTC 2011) 
Copyright 2004 Free Software Foundation, Inc. 
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() 
+0

NSZombiesを有効にしていますか? (ただのアイデア) – Peres

+0

それらを試してみましたが、何も報告しませんでした – shmuelie

答えて

0

あなたは、古典的なメモリ管理を行いました間違い:あなたはイヤーズに直接アクセスしていて、あなたを焼きました。

_friends = [NSMutableArray array]; 

_friends前の値を持っていた場合にも可能漏れアンダー保持(後にクラッシュする)であり、。あなたはいつものdeallocし、initを除いて、あなたのアイバーズに対するアクセサを使用する必要があります。

self.friends = [NSMutableArray array]; 
... 
[self.friends addObject:f]; 

EDIT:あなたのスタックトレースから、あなたのバグがあなたのテーブルビューのデータソースのtableView:heightForRowAtIndexPath:です。あなたの配列の最後を読んでいるようです。

+0

私はそれのためのプロパティを追加する必要がありますしようとすると、右か? – shmuelie

+0

はい、そうすべきです。 – Peres

+0

これを非原子的な属性として追加しましたが、それでも同じようにクラッシュしました。良いアイデアが、まだこの問題を解決していない、ありがとう! – shmuelie

関連する問題