gpt4 book ai didi

ios - '-[__NSCFString objectForKey :]: unrecognized selector sent to instance 0x9c515c0'

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:16:04 24 4
gpt4 key购买 nike

先生的问题是——我正在从 url 和 arrayobj 中获取数据。当我运行这个项目时,我收到了这个错误。我在项目中做了什么错误的语句或代码,请检查 connectiondidfinishloadingcellforrowanindexpath

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSError *error ;
NSMutableDictionary *dictobj = [NSJSONSerialization JSONObjectWithData:dataobj options:NSJSONReadingMutableContainers error:&error];

newsobj=[dictobj objectForKey:@"news"];

//NSArray *longdeceobj=[newsobj objectForKey:@"long_desc"];

for (NSDictionary *dict in newsobj)
{
NSDictionary *title=[dict objectForKey:@"title"];
[arrayobj addObject:title];
}
[[self tableobj]reloadData];
}

//这是索引路径代码处行的单元格

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString*cellide=@"identifier";
newcustomobj=(newsCustamView *) [tableView dequeueReusableCellWithIdentifier:cellide];
if (newcustomobj==nil)
{
[[NSBundle mainBundle]loadNibNamed:@"newsCustamView" owner:self options:nil];
}
newcustomobj.newstitle.text=[[[arrayobj objectAtIndex:0]objectForKey:@"news"]objectForKey:@"title"];
return newcustomobj;
}

错误是:

2014-05-23 18:34:04.913 newsdata[6518:90b] -[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x9c515c0
2014-05-23 18:34:04.915 newsdata[6518:90b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x9c515c0'
*** First throw call stack:
(
0 CoreFoundation 0x01b851e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x015cb8e5 objc_exception_throw + 44
2 CoreFoundation 0x01c22243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01b7550b ___forwarding___ + 1019
4 CoreFoundation 0x01b750ee _CF_forwarding_prep_0 + 14
5 newsdata 0x00008a13 -[ViewController tableView:cellForRowAtIndexPath:] + 435
6 UIKit 0x0038411f -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 412
7 UIKit 0x003841f3 -[UITableView _createPreparedCellForGlobalRow:] + 69
8 UIKit 0x00365ece -[UITableView _updateVisibleCellsNow:] + 2428
9 UIKit 0x0037a6a5 -[UITableView layoutSubviews] + 213
10 UIKit 0x002fa964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
11 libobjc.A.dylib 0x015dd82b -[NSObject performSelector:withObject:] + 70
12 QuartzCore 0x03dcd45a -[CALayer layoutSublayers] + 148
13 QuartzCore 0x03dc1244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
14 QuartzCore 0x03dc10b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
15 QuartzCore 0x03d277fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
16 QuartzCore 0x03d28b85 _ZN2CA11Transaction6commitEv + 393
17 QuartzCore 0x03d29258 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
18 CoreFoundation 0x01b4d36e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
19 CoreFoundation 0x01b4d2bf __CFRunLoopDoObservers + 399
20 CoreFoundation 0x01b2b254 __CFRunLoopRun + 1076
21 CoreFoundation 0x01b2a9d3 CFRunLoopRunSpecific + 467
22 CoreFoundation 0x01b2a7eb CFRunLoopRunInMode + 123
23 GraphicsServices 0x03c8f5ee GSEventRunModal + 192
24 GraphicsServices 0x03c8f42b GSEventRun + 104
25 UIKit 0x0028bf9b UIApplicationMain + 1225
26 newsdata 0x000119cd main + 141
27 libdyld.dylib 0x02330725 start + 0
28 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

最佳答案

你假设的变量 dictobj 是一个 NSDictionary,实际上它是一个 NSString。由于字符串不响应 objectForKey: 方法,您的应用程序崩溃了。这就是错误消息告诉您的内容。检查这个link .了解更多详情。

关于ios - '-[__NSCFString objectForKey :]: unrecognized selector sent to instance 0x9c515c0',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23830190/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com