設定:
ViewController
MyArray
からのオブジェクトのを保持しますPersonClass
。
PersonClass
との2つのプロパティがname
ありage
ます。
問題:
これを行うための適切な方法name
で、最初のオブジェクトからプロパティを読み取りたい場合はどうすればよいですか?MyArray
このようなインスタンスを一時的に作成する必要がありますPersonClass
か?
PersonClass *tmp = [PersonClass alloc] init];
tmp = [MyArray objectAtIndex:0];
NSLog(@"%@", tmp.name);
properties
または、ののobjects
を直接参照できMyArray
ますか?
このようなもの:
NSLog(@"%@", [self.contactsArray objectAtIndex:0].name); // not working