編輯:的Objective-C - >刪除最後一個元素的NSDictionary
驗證碼:問題
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSData *responseData = [request responseData];
NSString *json = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSDictionary *qs = [json objectFromJSONString];
self.questions = qs;
NSLog(@"%@", questions);
[json release];
[self setQuestions];
[load fadeOut:load.view withDuration:0.7 andWait:0];
UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithTitle:@"Start" style:UIBarButtonItemStylePlain target:self action:@selector(start:)];
self.navigationItem.rightBarButtonItem = anotherButton;
}
我有一個NSDictionary以下項目
//商店詞典:
(
{
max = 120;
min = 30;
question = "Morning Bodyweight (Kg)";
questionId = 1;
questionNumber = 1;
sectionId = 1;
type = TextInput;
},
{
question = "Morning Urine Colour";
questionId = 2;
questionNumber = 2;
sectionId = 1;
type = ImagePicker;
},
{
max = 120;
min = 30;
question = "Evening Bodyweight (Kg)";
questionId = 3;
questionNumber = 3;
sectionId = 1;
type = TextInput;
},
{
question = "Evening Urine Colour";
questionId = 4;
questionNumber = 4;
sectionId = 1;
type = ImagePicker;
},
{
max = 90;
min = 40;
question = "Morning Heart Rate (BPM)";
questionId = 5;
questionNumber = 5;
sectionId = 1;
type = TextInput;
},
{
question = "Time of Month (TOM)";
questionId = 6;
questionNumber = 6;
sectionId = 1;
type = Option;
}
)
我想刪除最後一個元素:
{
question = "Time of Month (TOM)";
questionId = 6;
questionNumber = 6;
sectionId = 1;
type = Option;
}
是否存在與NSDictionary相當的pop()?如果不是如何去除最後一個元素?
看起來像是一個數組的nsdictionaries,是否正確? –
是這些對象數組嗎?如果是這樣,你總是可以刪除最後一個元如果他們是對象的字典,並且對象具有所有這些字段。關鍵是什麼?時間戳? – user281300
它是一個數據庫元組的字符串..我使用jsonkit來反序列化json字符串並將其分配給nsdictionary。代碼在上面。 nslog輸出上面的nsdictionary – user559142