开发者

UITable cellForRowAtIndexPath

New in iOS, here is Question:

I am using xcode 4.0.2 iso-4.3.2. Here I have a table and I am creating one mutable array like

mainarray=[[NSMutableArray alloc]initWithObjects:@"Hi",@"Hello"nil];

and sending that value to.Table delegate method like

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

here value is coming but once I am sending dynamically value to the mainarray like

mainarray=[[NSMutableArray alloc]initWithObjects:[dataarray valueForKey:@"first_name"],nil]; or
[mainarray addobject:[dataarray valueForKey:@"first_name"]]

and sending that mainarray value to cell.textlabel.text then my program is terminating and sending this error message.

2011-05-11 10:29:10.346 picture:vide[742:207] -[__NSArrayI isEqualToString:]: unrecognized selector sent to instance 0x4e85200
2011-05-11 10:29:10.348 picture:vide[742:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI isEqualToString:]: unrecognized selector sent to instance 0x4e85200'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00ddb5a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x00f2f313 objc_exception_throw + 44
    2   CoreFoundation                      0x00ddd0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x00d4c966 ___forwarding___ + 966
    4   CoreFoundation                      0x00d4c522 _CF_forwarding_prep_0 + 50
    5   UIKit                               0x003ecafc -[UILabel开发者_Go百科 setText:] + 72
    6   picture:vide                        0x000050c9 -[VideoChatController1 tableView:cellForRowAtIndexPath:] + 376
    7   UIKit                               0x00340b98 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 634
    8   UIKit                               0x003364cc -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75
    9   UIKit                               0x0034b8cc -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
    10  UIKit                               0x0034390c -[UITableView layoutSubviews] + 242
    11  QuartzCore                          0x01d7ba5a -[CALayer layoutSublayers] + 181
    12  QuartzCore                          0x01d7dddc CALayerLayoutIfNeeded + 220
    13  QuartzCore                          0x01d230b4 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
    14  QuartzCore                          0x01d24294 _ZN2CA11Transaction6commitEv + 292
    15  QuartzCore                          0x01d2446d _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99
    16  CoreFoundation                      0x00dbc89b __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27
    17  CoreFoundation                      0x00d516e7 __CFRunLoopDoObservers + 295
    18  CoreFoundation                      0x00d1a1d7 __CFRunLoopRun + 1575
    19  CoreFoundation                      0x00d19840 CFRunLoopRunSpecific + 208
    20  CoreFoundation                      0x00d19761 CFRunLoopRunInMode + 97
    21  GraphicsServices                    0x017321c4 GSEventRunModal + 217
    22  GraphicsServices                    0x01732289 GSEventRun + 115
    23  UIKit                               0x002d9c93 UIApplicationMain + 1160
    24  picture:vide                        0x00002910 main + 102
    25  picture:vide                        0x000028a1 start + 53
)

Please, help.


Here you are getting this terminating log because

dataArray is an NSArray you can't call [dataarray valueForKey:@"first_name"] this because this unreconised for NSArray

rether than this you may use some thing like this

[[dataarray objectAtIndex:index] valueForKey:@"first_name"]


[__NSArrayI isEqualToString:]: is the issue. You are using the isEqualToString: for an array somewhere. Check that. Its a method of NSString


Initialization of array was wrong.

Following line

mainarray=[[NSMutableArray alloc]initWithObjects:@"Hi",@"Hello"nil];

should be corrected as

mainarray=[[NSMutableArray alloc]initWithObjects:@"Hi",@"Hello" , nil];

Please note the new comma between @"Hello" and nil

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜