Heyo Guys
So I am more or less new to Objective C and got to a problem which I seem unable to solve.
I created a class called "Students" which all have a name surname etc. All those Students are put into a NSMutableArray
(before they get created from JSON , that seems to work without a problem though). Then all the names of the students are put into a ListView
. Afterwards when a name is clicked (segue passes the object), one should see the details of said student (i.e. his full name, his id, his street).
The problem is that all the string values of the student object seem to get lost.
I checked that all the student object work just fine. I think the problem lies at the @property in my student class.
Any comments and suggestions are appreciated
This is an excerpt of student.h As said only the string values get lost, the int (here the plz value) remains correct
@property (nonatomic, weak)NSString *lastname;
@property (nonatomic, weak)NSString *surname;
@property (nonatomic, weak)NSString *street;
@property (nonatomic, assign)int plz;
EDIT: Here is where i parse my json.
for (NSDictionary *dic in jsonArray){
NSNumber *identity = [dic valueForKey:@"id"] ;
NSString *firstName = (NSString*) [dic valueForKey:@"first_name"];
NSString *lastName = (NSString*) [dic valueForKey:@"last_name"];
NSString *street = (NSString*) [dic valueForKey:@"street"];
NSNumber *plz = [dic valueForKey:@"plz"] ;
NSString *birth = (NSString*) [dic valueForKey:@"date_of_birth"];
NSArray *bills = dic[@"bills"];
NSArray *hours = dic[@"hours"];
NSLog(@"First %@",firstName);
Student *student = [[Student alloc]initWithLastName:lastName withSurname:firstName withStreet:street withPLZ:plz withOrt:@"Uitikon" withBirthDate:birth withOccupation:@"Schüler"];
[ApprenticeList addObject:student];
}
EDIT 2 :
I found out that the string values get lost even before the segue. All these objects are created in
ViewDidLoad
But in
prepareforsegue
all the values are allready null (except for the int) .So the only place where the student objects work is in
ViewdidLoad