use*_*142 0 iphone xcode 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;
}
Run Code Online (Sandbox Code Playgroud)
我在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;
}
)
Run Code Online (Sandbox Code Playgroud)
我想删除最后一个元素:
{
question = "Time of Month (TOM)";
questionId = 6;
questionNumber = 6;
sectionId = 1;
type = Option;
}
Run Code Online (Sandbox Code Playgroud)
NSDictionary是否有pop()等价物?如果不是如何删除最后一个元素?
字典没有顺序所以没有"最后一个对象"
但是,这可能会解决您的问题,但可能并不总是删除您认为"最后一个对象"的内容:
[dictionaryName removeObjectForKey:[[dictionaryName allKeys] lastObject]];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3649 次 |
| 最近记录: |