I am following this tutorial: https://www.youtube.com/watch?v=4_0Ao11zrtM
I am trying to make a login box similar to the one in the video, but for a cocoa app on OS X. I am fairly new at objective-c, and this is my first app.
Here is the current code for my LoginController.m file:
#import "LoginController.h"
@implementation LoginController
- (void)awakeFromNib {
[prodigyLabel setTextColor:[NSColor orangeColor]];
[studioLabel setTextColor:[NSColor darkGrayColor]];
loginDictionary = [[NSDictionary alloc] initWithObjects:@"password" forKeys:@"username"];
}
- (IBAction)loginButtonPressed:(id)sender {
}
@end
The loginDictionary part was modified because I looked online and thought it might help when I found it on a different site, hence it says NSDictionary alloc.
It originally said:
loginDictionary = [[NSArray alloc] initWithObjects:@"password", nil];
But there is no option for "forKeys" as seen in the tutorial.
I keep getting error:
Incompatible pointer types sending 'NSString *' to parameter of type 'NSArray *'
Please help me. I am trying to make the dictionary and add the usernames and passwords to it like in the tutorial. What am I doing wrong??
If you want to add the usernames and passwords to your dictionary, the dictionary shoud be mutable , you can do like this:
loginDictionary = [NSMutableDictionary dictionary];
[loginDictionary setObject:@"your username" forKey:@"username"];
[loginDictionary setObject:@"your password" forKey:@"password"];
the loginDictionary must be a NSMutableDictionary.