Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

matthew858

macrumors member
Original poster
Apr 15, 2008
97
0
Sydney, Australia
I am making an application that has an account linked to it. The first time the app is launched, the user enters their username and password. These details are then stored in NSStrings. What I want to do is, on launch, check whether the username string is empty or contains a username (if the app has launched before). I have the following code:

AppDelegate:
Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
	
	NSUserDefaults *twitterUsername = [NSUserDefaults standardUserDefaults];
	username = [twitterUsername stringForKey:@"twitter username"];
	
	if(username == nil) {
		[self firstTimeWelcomeMessage];
	}		
	
    [window addSubview:tabBarController.view];
	
}


After username and password entry:
Code:
username = usernameTextField.text;
password = passwordTextField.text;


How would I go about putting the variable "username" into the NSUserDefault Twitter Username and have it successfully recognise on start-up that there is something stored in Twitter Username?
 

matthew858

macrumors member
Original poster
Apr 15, 2008
97
0
Sydney, Australia
Thanks for that. I have established I need the following:
Code:
[setObject:(id)username forKey:(NSString *)twitterUsername];

Can I just put this on a new line after username has been declared?
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Thanks for that. I have established I need the following:
Code:
[setObject:(id)username forKey:(NSString *)twitterUsername];

Can I just put this on a new line after username has been declared?

I suggest you need to read up on basic Objective-C as that is nothing like a valid method call. You need to learn the basics of the language before you try and write an application.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.