Hi, I'm new here and I'm pretty noob (as you can see) at programming, I've only a bit of experience with Javascript so I've some troubles looking at objc and xcode for the first time... that's why I would like to ask you some help
To be short I'm trying to make a simple app which gets data (a name and a value) from a UITextField and UIlabel.
I have a "sender" button too, i would like to use the sender button to set the NSMutableDictionary, my first idea was to set a key and as value an object (an array of numbers), in this code you won't find out any array for now, i just want to make it works the dictionary first
the app is working well (except for the dictionary) and i know you'll find a lot of mistakes so advise me without any mercy, i'll be glad to learn
here is the code, i've colored the part of interest:
ViewController.h
ViewController.m
main.m
i've added a picture that show both pages of what i'm trying to do, in the first page you'll see the structure of how to write and send values, in the second (which is clean) i wanted to store my list from the NSMutableDictionary (but before i need it to work eheh)
of course i'm missing something important but since I can't figure out what looking in the web i've decided to try and ask you any help hope you want to help me, thanks a lot in advance
Carll
To be short I'm trying to make a simple app which gets data (a name and a value) from a UITextField and UIlabel.
I have a "sender" button too, i would like to use the sender button to set the NSMutableDictionary, my first idea was to set a key and as value an object (an array of numbers), in this code you won't find out any array for now, i just want to make it works the dictionary first
the app is working well (except for the dictionary) and i know you'll find a lot of mistakes so advise me without any mercy, i'll be glad to learn
here is the code, i've colored the part of interest:
ViewController.h
Code:
@interface ViewController : UIViewController {
IBOutlet UIView *votePage;
IBOutlet UIView *archivePage;
[COLOR="orange"]NSMutableDictionary *mutableDictionary;
[/COLOR]
}
-(IBAction) archivePage;
-(IBAction) votePage;
[COLOR="Orange"]@property (retain, nonatomic) NSMutableDictionary *mutableDictionary;
[/COLOR]@property (retain, nonatomic) IBOutlet UILabel *myLabel;
@property (retain, nonatomic) IBOutlet UITextField *myTextView;
@property (retain, nonatomic) IBOutlet UILabel *myVote;
@end
ViewController.m
Code:
@interface ViewContorller()
@end
@implementation ViewController
@synthesize mutableDictionary;
-(IBAction)votePage: (id)sender {
self.view = votePage;
}
-(IBAction)archivePage: (id)sender {
self.view = archivePage;
}
-(IBAction)myTextView: (id)sender {
}
-(IBAction)sendVote: (id)sender {
[self.myTextView resignFirstResponder];
self.myLabel.text = self.myTextView.text;
[COLOR="orange"][mutableDictionary setValue:self.myVote.text forKey:self.myTextView.text];
[/COLOR]
}
-(IBAction)addVote: (UIStepper*)sender {
NSUInteger value = sender.value;
self.myVote.text = [NSString stringWithFormat:@"%d",value];
}
-(void)viewDidLoad
{
[super viewDidLoad];
self.view = votePage;
}
-(void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
-(void) dealloc {
[_myLabel release];
[_myTextView release];
[_myVote release];
[super dealloc];
}
@end
main.m
Code:
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
[COLOR="orange"] NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"10", @"First Collection", nil];
NSLog(@"mutableDictionary = %@", mutableDictionary);[/COLOR]
}
i've added a picture that show both pages of what i'm trying to do, in the first page you'll see the structure of how to write and send values, in the second (which is clean) i wanted to store my list from the NSMutableDictionary (but before i need it to work eheh)
of course i'm missing something important but since I can't figure out what looking in the web i've decided to try and ask you any help hope you want to help me, thanks a lot in advance
Carll
Last edited by a moderator: