How to use NSObject subclass?

Posted by Jon on Stack Overflow See other posts from Stack Overflow or by Jon
Published on 2012-04-07T23:07:26Z Indexed on 2012/04/07 23:29 UTC
Read the original article Hit count: 227

Filed under:
|
|
|

So I've created a subclass of NSObject called Query

@interface Query : NSObject

@property (nonatomic, assign) NSNumber *weight;
@property (nonatomic, assign) NSNumber *bodyFat;
@property (nonatomic, assign) NSNumber *activityLevel;

@end

Is this correct for setting the object's property?

In VC1:

BodyFatViewController *aViewController = [[BodyFatViewController alloc]init];
aViewController.query = self.query;
[self.navigationController pushViewController:aViewController animated:YES];

In VC2:

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
    Query *anQuery = [[Query alloc]init];
    anQuery.bodyFat = [self.bodyFatArray objectAtIndex:row];
    anQuery.weight = self.query.weight;
    self.query = anQuery;
}

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c