【发布时间】:2015-05-26 14:05:47
【问题描述】:
我需要在
中执行方法- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
我有一个NSDictionary,我想从中获取 ID(长)并将其发送到我的方法:
long sect = (long)section;
[objectp.methodA countRowsInSection:[tableSections objectForKey:[NSString stringWithFormat:@"%ld", sect]]]
我收到警告:
Incompatible pointer to integer conversion sending 'id' to parameter of type 'long'
为什么?
我尝试将NSInteger 转换为long,然后再转换为NSString,但警告仍然存在。
备注: countRowsInSection 是 long。
我将NSDictionary中的数据存储为NSString:
[tableSections setValue:[NSString stringWithFormat:@"%ld", newCategoryID]
forKey:[NSString stringWithFormat:@"%ld", counter]];
【问题讨论】:
-
格式中使用的
sect变量是什么类型的? -
对不起@rckoenes,它是
long-long sect = (long)section; -
尝试溢出该方法,这可能会让您更好地了解错误所在。因为现在我看不出你的代码有什么问题。
-
仔细查看编译器用来显示错误所在的小箭头。它不是警告您有关教派的信息。它会警告您传递给 countRowsInSection 的对象:
标签: objective-c nsdictionary type-conversion