2012-04-07 16 views
0

テーブルに複数のツイートを読み込むテーブルビューを作成しようとしています(セルごとに1つなど)。テーブルセルに配列データを追加するとアプリケーションがクラッシュする

NSXMLParserを使用して情報を取得していますが、私が望むつぶやきの選択肢を含む配列を作成しています。

しかし、私はテーブルセルに追加しようとすると、ライン上のアプリのクラッシュ:

cell.textLabel.text = cellValue; 

アンのNSLogこのアプリは、正しいデータを取得しているコンソールに示し前に、私はなぜこれが機能していないのか、ちょっと困惑しています。

これが問題を抱えているように見えるコードのブロックです:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

static NSString *CellIdentifier = @"Cell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
    } 

// Set up the cell... 
NSString *cellValue = [statuses objectAtIndex:indexPath.row]; 
NSLog(@"%@", cellValue); 


cell.textLabel.text = cellValue; 

return cell;} 

それが違いをした場合、私はARCとXcodeの最新版を使用しています。

私はまだこのすべてに新しいので、私はいくつかの追加情報を与える必要がある場合は、私に教えてください。

ありがとうございます。

編集:

バックトレースには、次を与える:

* thread #1: tid = 0x2003, 0x918a19c6 libsystem_kernel.dylib`__pthread_kill + 10, stop reason = signal SIGABRT 
frame #0: 0x918a19c6 libsystem_kernel.dylib`__pthread_kill + 10 
frame #1: 0x9968ff78 libsystem_c.dylib`pthread_kill + 106 
frame #2: 0x99680bdd libsystem_c.dylib`abort + 167 
frame #3: 0x03c93e78 libc++abi.dylib`_Unwind_DeleteException 
frame #4: 0x03c9189e libc++abi.dylib`_ZL17default_terminatev + 34 
frame #5: 0x0154df4b libobjc.A.dylib`_objc_terminate + 94 
frame #6: 0x03c918de libc++abi.dylib`_ZL19safe_handler_callerPFvvE + 13 
frame #7: 0x03c91946 libc++abi.dylib`std::terminate() + 23 
frame #8: 0x03c92ab2 libc++abi.dylib`__cxa_throw + 110 
frame #9: 0x0154de15 libobjc.A.dylib`objc_exception_throw + 311 
frame #10: 0x013bdced CoreFoundation`-[NSObject doesNotRecognizeSelector:] + 253 
frame #11: 0x01322f00 CoreFoundation`___forwarding___ + 432 
frame #12: 0x01322ce2 CoreFoundation`_CF_forwarding_prep_0 + 50 
frame #13: 0x0015168f UIKit`-[UILabel setText:] + 56 
frame #14: 0x00003088 Twitter`-[TwitterViewController tableView:cellForRowAtIndexPath:] + 376 at TwitterViewController.m:131 
frame #15: 0x000ace0f UIKit`-[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 494 
frame #16: 0x000ad589 UIKit`-[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 69 
frame #17: 0x00098dfd UIKit`-[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1350 
frame #18: 0x000a7851 UIKit`-[UITableView layoutSubviews] + 242 
frame #19: 0x00052301 UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 145 
frame #20: 0x013bde72 CoreFoundation`-[NSObject performSelector:withObject:] + 66 
frame #21: 0x01d6692d QuartzCore`-[CALayer layoutSublayers] + 266 
frame #22: 0x01d70827 QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 231 
frame #23: 0x01cf6fa7 QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 377 
frame #24: 0x01cf8ea6 QuartzCore`CA::Transaction::commit() + 374 
frame #25: 0x01d8430c QuartzCore`+[CATransaction flush] + 52 
frame #26: 0x000124c6 UIKit`-[UIApplication _reportAppLaunchFinished] + 39 
frame #27: 0x00012bd6 UIKit`-[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 1324 
frame #28: 0x00021743 UIKit`-[UIApplication handleEvent:withNewEvent:] + 1027 
frame #29: 0x000221f8 UIKit`-[UIApplication sendEvent:] + 68 
frame #30: 0x00015aa9 UIKit`_UIApplicationHandleEvent + 8196 
frame #31: 0x012a6fa9 GraphicsServices`PurpleEventCallback + 1274 
frame #32: 0x013901c5 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53 
frame #33: 0x012f5022 CoreFoundation`__CFRunLoopDoSource1 + 146 
frame #34: 0x012f390a CoreFoundation`__CFRunLoopRun + 2218 
frame #35: 0x012f2db4 CoreFoundation`CFRunLoopRunSpecific + 212 
frame #36: 0x012f2ccb CoreFoundation`CFRunLoopRunInMode + 123 
frame #37: 0x000122a7 UIKit`-[UIApplication _run] + 576 
frame #38: 0x00013a9b UIKit`UIApplicationMain + 1175 
frame #39: 0x0000239d Twitter`main + 141 at main.m:16 
frame #40: 0x00002305 Twitter`start + 53 

コンソールのデバッグは、このことを示しています

2012-04-08 10:10:05.084 Twitter[25309:f803] (
    { 
    text = "Have you shared the Shakedown yet? http://t.co/WHrIC9w7"; 
}, 
    { 
    text = "For all you closet rocknrollas pencil in Sat 12th May The Rebirth of Rock n Roll Party. Haywire Saint @ The Good... http://t.co/OXHKlLIV"; 
}, 
    { 
    text = "4 weeks today: Vocal tracks will be getting recorded at The Premises Studios"; 
}, 
    { 
    text = "Rehearsal tonight in preparation to some big recording next month!"; 
}, 
    { 
    text = "haywire saint 'great taste.' Tune. \n\nhttp://t.co/GKmu5Lna http://t.co/0fii55Hw"; 
}, 
    { 
    text = "Meeting up with an old roadie for The Cure today. oh the stories...... http://t.co/UeUYccme"; 
}, 
    { 
    text = "Satisfying day of programming today.. Haywire Saint app coming along nicely with the custom music player ready to rock 'n' roll!"; 
}, 
    { 
    text = "Happy Friday Everyone!"; 
}, 
    { 
    text = "We had a great time at The Premises Studios yesterday. We'll be back there before long :D x"; 
}, 
    { 
    text = "I posted a new photo to Facebook http://t.co/73qAnCvk"; 
} 
) 

2012-04-08 10:10:05.093 Twitter[25309:f803] { 
text = "Have you shared the Shakedown yet? http://t.co/WHrIC9w7"; 
} 

2012-04-08 10:10:05.094 Twitter[25309:f803] -[__NSCFDictionary isEqualToString:]:  unrecognized selector sent to instance 0x6877a50 
2012-04-08 10:10:05.096 Twitter[25309:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary isEqualToString:]: unrecognized selector sent to instance 0x6877a50' 
*** First throw call stack: 
(0x13bc052 0x154dd0a 0x13bdced 0x1322f00 0x1322ce2 0x15168f 0x3088 0xace0f 0xad589 0x98dfd 0xa7851 0x52301 0x13bde72 0x1d6692d 0x1d70827 0x1cf6fa7 0x1cf8ea6 0x1d8430c 0x124c6 0x12bd6 0x21743 0x221f8 0x15aa9 0x12a6fa9 0x13901c5 0x12f5022 0x12f390a 0x12f2db4 0x12f2ccb 0x122a7 0x13a9b 0x239d 0x2305) 
terminate called throwing an exception2012-04-08 10:10:05.924 Twitter[25309:f803] -[__NSCFConstantString count]: unrecognized selector sent to instance 0x5b30 
+0

クラッシュの性質は何ですか?バックトレースは何ですか? –

+0

シュート、申し訳ありません、それはスレッド1でした:シグナルsigabrt。私はバックトレースが何であるか分かりませんが、クラッシュがmain.mに行きません。cell.textLabel.text = cellValue;行をハイライト表示します。そのエラーを私に与える。 – bassmandan

+0

SIGABRTはおそらく、アサーションが発砲されたか、例外が発生したことを意味します。その詳細がデバッグコンソールに記録されているはずです。スタックトレースまたはコールトレースとも呼ばれるバックトレースは、プログラムの実行の特定のポイントにつながった一連の呼び出しを示します。デバッグコンソールでは、おそらく "bt"と入力してバックトレースをここに投稿することができます。 –

答えて

1

statuses配列は辞書ではなく、文字列を保持するようです。各辞書には単一のキー「テキスト」があります。

だから、あなたが行変更することでクラッシュを修正できます。また

NSString *cellValue = [[statuses objectAtIndex:indexPath.row] objectForKey:@"text"]; 

NSString *cellValue = [statuses objectAtIndex:indexPath.row]; 

をあなたは違っstatuses配列を作成した場合、あなたはそれが直接文字列を含む作ることができます辞書に不要に包まれることなく。どのように構築しているのかわからなければ、その部分を修正する方法を教えるのは難しいです。正確なオブジェクトの種類を見つけるために

NSLog(@"%@", [cellValue class]); 

または

NSLog(@"%i", [cellValue isKindOfClass:[NSString class]]); 

cell.textLabel.text = cellValue; 

試してみてください。この行の前にして

+0

これはすばらしいおかげだ、それは今働いている(と私は辞書と文字列の違いも理解している!)。私はあなたにパイントを借りています。 – bassmandan

1

cell.textLabel.textは、NSString *を必要としています。

関連する問題