I got some problems with my properties of NSManagedObject(UserInformations)
In the second method I request the value of the userGender
which I set in the method before. But why doesn't userGender
keep his value?
UserInformations.h
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@interface UserInformations : NSManagedObject
...
@property (nonatomic) int32_t userGender;
UserInformations.m
@dynamic userGender;
Thats my Viewcontroller:
GenderViewController.h
#import <UIKit/UIKit.h>
@class UserInformations;
...
@property (nonatomic, strong) UserInformations *item;
GenderViewController.m
...
@synthesize item;
...
- (IBAction)pickedFemale:(id)sender {
StoreThem *st = [[StoreThem alloc] init];
NSManagedObjectContext *context = [st managedObjectContext];
item = [NSEntityDescription insertNewObjectForEntityForName:@"UserInfos"
inManagedObjectContext:context];
NSNumber *someNumber = [NSNumber numberWithInt:3];
[item setValue:someNumber forKey:@"userGender"];
NSLog(@"%d", [item userGender]);
//NSLog says 3
}
- (IBAction)nextView:(id)sender {
NSLog(@"%d", [item userGender]);
//NSLogs says 0
if ([item userGender] == 0) {
return;
}
InfoViewController *mvc = [[InfoViewController alloc] init];
[[self navigationController] pushViewController:mvc animated:YES];
}