所以我有一个NSArray带有NSNumbers和NSStrings 的"myArray" .我需要他们在另一个,UIView所以我这样:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
DetailViewController *details = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil];
details.subjectText = [[myArray objectAtIndex:indexPath.row] objectForKey:@"subject"];
Run Code Online (Sandbox Code Playgroud)
subjectText工作.但是我怎样才能从中获得NSNumber它?(其实我需要他们的细绳...)我想转换NSString出来的NSNumber是这样的:
NSString *blah = [NSNumber intValue].但我不知道如何在上面的代码中设置它...
我有一个我在谷歌找不到的小问题:
UITableView工作正常,直到我开始滚动.
Error Message: `-[NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x5f24870 `
Run Code Online (Sandbox Code Playgroud)
方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
}
// Set up the cell
int storyIndex = [indexPath indexAtPosition: [indexPath length]-1];
//populate cell
cell.textLabel.text = [[myArray objectAtIndex: storyIndex] objectForKey: @"subject"];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
只是猜到这是"问题" - 方法......如果您需要更多信息:请告诉我:)感谢您的帮助!
编辑:myArray只是正常NSArray *myArray
它是一个排序的数组 - >
NSSortDescriptor *sortDescriptor …Run Code Online (Sandbox Code Playgroud)