How to store array in local file in ios?

349 Views Asked by At

I am building an iOS app using storyboards.I am sending login profile information to server and getting response from the server as a user id i want to save this id in my local file and use in my project in different classes.

I'm unable to do this could someone help me how i can do this.

1

There are 1 best solutions below

0
On

Login data should not be stored in files or userdefault. I suggest storing it in an NSKeychain.

Additionally, if you need to keep it for local reference in current project scope, make a class that manages these properties and use dependency injection to pass around the class holding the properties.

check out the nsuserdefault docs for cases of when to use / not use them.

https://developer.apple.com/library/ios/documentation/cocoa/reference/Foundation/Classes/NSUserDefaults_Class/index.html