У меня есть класс с именем "Book", и исходный код выглядит следующим образом: -
Book.h
#import <"UIKit/UIKit.h>
@interface Book : NSObject {
NSInteger bookID;
NSString *title; //Same name as the Entity Name.
NSString *author; //Same name as the Entity Name.
NSString *summary; //Same name as the Entity Name.
}
@property (nonatomic, readwrite) NSInteger bookID;
@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) NSString *author;
@property (nonatomic, retain) NSString *summary;
@end
Book.m
#import "Book.h"
@implementation Book
@synthesize title, author, summary, bookID;
-(void) dealloc {
[summary release];
[author release];
[title release];
[super dealloc];
}
@end
Тогда в другом классе я могу написать: -
Book *aBook = [[Book alloc]init];
[aBook setValue:currentElementValue forKey:elementName];
Если да, то почему ??Потому что обычно setvalue и forkey используются для хранения данных в NSMutableDictionary ..