dav*_*av3 132 objective-c nsnumber nsstring nsarray
所以我有一个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].但我不知道如何在上面的代码中设置它...
Jon*_*LOo 374
尝试:
NSString *myString = [NSNumber stringValue];
Run Code Online (Sandbox Code Playgroud)
小智 13
你可以这样做:
NSNumber *myNumber = @15;
NSString *myNumberInString = [myNumber stringValue];
Run Code Online (Sandbox Code Playgroud)
小智 7
//An example of implementation :
// we set the score of one player to a value
[Game getCurrent].scorePlayer1 = [NSNumber numberWithInteger:1];
// We copy the value in a NSNumber
NSNumber *aNumber = [Game getCurrent].scorePlayer1;
// Conversion of the NSNumber aNumber to a String with stringValue
NSString *StringScorePlayer1 = [aNumber stringValue];
Run Code Online (Sandbox Code Playgroud)
或尝试 NSString *string = [NSString stringWithFormat:@"%d", [NSNumber intValue], nil];
| 归档时间: |
|
| 查看次数: |
176824 次 |
| 最近记录: |