【发布时间】:2011-03-12 04:58:25
【问题描述】:
我正在appdelegate 上实现以下功能,
但我需要写 NSString 类型而不是典型的浮点值。
由于 xcode 不允许对象位于我想要的位置,
我使用char* 代替如下,因为我要传递的数据类型为NSString。
正如预期的那样,它不起作用...
我该如何操作它以便我可以编写 NSString 数据类型?
我应该进行一些转换吗?
请帮帮我..
- (void)addHallOfFamer:(char*)newHofer{
[hofArray addObject:[NSString stringWithFormat:@"%@",newHofer]];
[hofArray sortUsingSelector:@selector(compare:)];
NSArray* paths =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* documentsDirectory = [paths objectAtIndex:0];
NSString* hofArrayPath = [documentsDirectory
stringByAppendingPathComponent:@"hofers.plist"];
[hofArray writeToFile:hofArrayPath atomically:YES];
}
(添加) 以下是我如何从另一个视图调用写入的 NSStrings,这并不反映我的更新。
MainAppDelegate* delegate;
delegate = (MainAppDelegate*)[[UIApplication sharedApplication] delegate];
NSArray *hofers = [[delegate.hofArray reverseObjectEnumerator] allObjects];
hoferName1.text = [NSString stringWithFormat:@"%@",[hofers objectAtIndex:0]];
【问题讨论】: