【发布时间】:2011-01-20 13:19:08
【问题描述】:
我的应用中有一个 NSString 问题。
我已经在视图控制器的头文件中定义了它。
NSString *locationCoordinates;
我在 -(void) 方法中设置它的值。
- (void)locationUpdate:(CLLocation *)location {
<...>
NSArray *locArray = [locString componentsSeparatedByString:@", "];
NSString *xCoordinate = [locArray objectAtIndex:0];
NSString *yCoordinate = [locArray objectAtIndex:1];
locationCoordinates = [NSString stringWithFormat:@"%@,%@", xCoordinate, yCoordinate];
}
在这种方法中,我可以将其打印到控制台
NSLog(locationCoordinates);
但如果我想在控制台中以其他方式查看它,我的应用会立即退出。
- (IBAction)saveAndReturnToRootView {
NSLog(locationCoordinates);
}
控制台告诉我:
2010-02-24 14:45:05.399 MyApp[73365:207] *** -[NSCFSet length]: unrecognized selector sent to instance 0x4c36490
2010-02-24 14:45:05.400 MyApp[73365:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFSet length]: unrecognized selector sent to instance 0x4c36490'
2010-02-24 14:45:05.401 MyApp[73365:207] Stack: (
32887899,
2434934025,
33269819,
32839286,
32691906,
32417461,
32527181,
32527085,
32747749,
356942,
630491,
63461,
2868313,
4782069,
2868313,
3275682,
3284419,
3279631,
2973235,
2881564,
2908341,
40984273,
32672640,
32668744,
40978317,
40978514,
2912259,
9744,
9598
)
我该如何解决这个问题?
提前致谢 ;-)
【问题讨论】:
标签: iphone objective-c memory crash nsstring