0

I have a class called business. The business class has properties "id", "name", "slogan", etc.

@interface Business : NSObject

@property (nonatomic) NSInteger id;

@property (nonatomic, strong) NSString *name;

@property (nonatomic, strong) NSString *slogan;

I created an instance of the object.

Business *newBusiness = [[Business alloc] initWithID:2];

This is where I need help. Say I wanted to call its "id" property, but want to do it through a variable.

NSString *property = @"slogan";

[newBusiness property] = @"We can do it!";

or

newBusiness.property = @"We can do it!";
yaserso
  • 2,638
  • 5
  • 41
  • 73
  • Your last question was a good one (fixable security problems notwithstanding). Why did you delete it? Very poor questions may be deleted, but the possibility that people are still typing out an answer needs to be rather borne in mind `:)`. – halfer Jun 23 '13 at 16:54

1 Answers1

3

id is a reserved word in Objective-C so change it to identity or some such.

As far as your question goes, you could use key-value coding?

trojanfoe
  • 120,358
  • 21
  • 212
  • 242