我可以在类之间传递基本数据,但是当我尝试NSString*
从我的传递 a 时UIApplicationDelegate
得到EXC_BAD_ACCESS
/ NSZombie
。
有什么特别的事情我必须做才能退货NSObject
吗?这与线程有关吗?(我以为atomic
物业的设置会解决这个问题?)
AppDelegate.h:
@interface AppDelegate : NSObject <UIApplicationDelegate> {
NSString * currentNoteName;
}
@property (atomic, assign) NSString *currentNoteName;
@end
AppDelegate.m:
- (void)timerCallback:(NSTimer *)timer {
currentNoteName = [NSString stringWithCString:(tone->freq).c_str() encoding:NSUTF8StringEncoding];
// This works:
NSLog(@"Current Note Name in timerCallback: %@", currentNoteName);
其他对象.m:
// Returns a Zombie object & EXC_BAD_ACCESS:
NSString *currentNoteName = [appDelegate currentNoteName];