-2
如何更改或更新NSMuttableDictionary我User.h適用以下更改或更新NSMuttableDictionary
代碼文件中的代碼
@interface User : NSObject
@property (nonatomic, strong) NSNumber *userID;
@property (nonatomic, strong) NSString *avatar;
@property (nonatomic, strong) NSString *firstname;
-(User *)initWithDictionary:(NSDictionary *)dictionary;
@end
然後在User.m文件中的代碼
#import "User.h"
@implementation User
@synthesize userID;
@synthesize avatar;
@synthesize firstname;
-(User *)initWithDictionary:(NSDictionary *)dictionary
{
self = [super init];
if (self)
{
self.userID = [dictionary objectForKey:@"IdUser"];
self.avatar = [dictionary objectForKey:@"Avatar"];
self.firstname = [dictionary objectForKey:@"FirstName"];
}
return self;
}
@end
在我的.pch文件中
#define AppDelegateInstance ((AppDelegate *)[UIApplication sharedApplication].delegate)
然後我得到了這樣的
AppDelegateInstance.loggedUser = [[User alloc] initWithDictionary:[tempArray objectAtIndex:0]];
Response == (
{
IdUser = 1;
Avatar = "Nishant_1.jpg
FirstName = Nishant;
}
)
現在所有鍵和值我的問題是如何更新
{
Avatar = "Nishant_1.jpg(Not update **Nishant_1.jpg** to **xyz.jpg**)
FirstName = Nishant(Not Update **Nishant** to **xyz**);
}
如果有人知道這PLZ給我一些答案來解決我的查詢
謝謝在高級!!!
什麼,你問你的財產的方法?想要修改密鑰的值。 –
@Kumar是...... – kagmanoj
[[responseAray objectAtindex:0] setValue:「youValue」forKey:@「Avatar」];然後在想要更改的地方做休息,並根據需要進行更正 –