objective c - IOS 7 Singleton Problems -
Hi, I know this is not a new question, but I read a lot here and nothing was able to help me find the problem.
I have a singleton class userfunction
@interface userfunction: NSOWJs {NSUser Defaults * NSUser; / * NSString * name; NSString * Email; * /} + (Userfunctions *) shared person; @protecti (nanatomic, assign) NSString * name; @protecti (nanatomic, assign) NSString * email;
On square meters:
@ synthesis name; @ Synthesis email; + (UserFunctions *) Shared Instances {Static User Function * Shared Instance; Static transmission_expression; Sending & amp; (& amp; Future, ^ {shareInstance = [[User Functions alloc] init];)); Return Share Instance; } - (id) init {if (self = [super init]) {NSUser = [NSUserDefaults StandardUserDefaults]; Itself = [NSUser objectForKey: @ "UserFunctions"]; Self.name = @ "test"; } Healthy return; }
I try to save to another class
UserFunction = [UserFunctions shareInstance]; UserFunction.name = userjson.username; UserFunction.email = userjson.email;
And if I try to read directly:
NSString * test = [Userfunction email]; itemprop = "text"> You should not use the property for the
property (unless you place the object elsewhere Can not keep)
@property (nonatomic, assign) NSString * name; @protecti (nanatomic, assign) NSString * email;
should be: (if you are using ARC)
@property (nonatomic, strong) NSString * name; @property (non-standard, strong) NSString * email; On a sidenote, one thing that bothers me reading your code: You should definitely not have an iVar named NSUser
It looks like a class name is very awesome and it's your code Is done while reading: