0

I store some data in NSUserDefaults and keychain and I have a wrapper. For example

- (NSString *)userPassword
{
    return [UICKeyChainStore stringForKey:KEY_USER_PASSWORD];
}

- (void)setUserPassword:(NSString *)userPassword
{
    [UICKeyChainStore setString:userPassword forKey:KEY_USER_PASSWORD];
}

How should properties definition look like? Now I use as follows

@property (nonatomic, strong) NSString *userEmail;

But now I have a doubt if I should use strong statement there since I haven't an ivar for it.

Thanks in advance.

efpies
  • 3,625
  • 6
  • 34
  • 45
  • 1
    You may use whatever type of property you want - since you write the methods, the compiler won't generate any code for them, so no memory issues (neither leaks nor overreleasing) shall occur. –  Dec 05 '12 at 16:33

2 Answers2

1

strong or weak both will be fine.

Its your custom method, this implies that you are overriding the compiler's method, or rather compiler will not create methods for those properties.

EDIT:

One more thing for you :)

Is there any advantage of having atomic property for saving in keychains/userdefaults?

Community
  • 1
  • 1
Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
0

You can use strong properties. Here you are implementing your own setter and getter which means you are only overriding the methods of compiler so If you want to use you can else it is also fine.

hites
  • 149
  • 1
  • 7