如何将一个 NSString 复制到另一个?
@interface MyData : NSObject
{
@private
//user's private info
NSInteger uID;
NSString *name;
NSString *surname;
NSString *email;
NSString *telephone;
//user's picture
UIImage *image;
}
@property (nonatomic, assign) int uID;
@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSString *surname;
@property (nonatomic, retain) NSString *email;
@property (nonatomic, retain) NSString *telephone;
@property (nonatomic, retain) UIImage *image;
@end
我有两个这种类型的对象。我的数据 *obj1, obj2;
首先是初始化。其次,我想先初始化。
obj2 = [obj1 copy]; //crashes
newData.surname = data.surname; //crashes to
newData.email = data.email;
newData.telephone = data.telephone;
我需要不保留第二个对象的副本!!!请帮忙!谢谢!