我刚才注意到,当我在我的 dealloc 方法中保存对象状态( @public float
s 转换为s )时,使用NSString
+(void)savePreferences:(NSString*)key :(NSString*)value{
NSMutableString* mutableString=[[NSMutableString alloc]initWithString:value];
CFPreferencesSetAppValue((CFStringRef)key, mutableString, kCFPreferencesCurrentApplication); // Set up the preference.
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);// Write out the preference data.
[mutableString release];
}
保存了错误的值!?如果我在发布之前保存值,则会保存正确的值。请注意,我[super dealloc];
在最后调用时很小心。为什么是这样?