English 中文(简体)
目 录 答复
原标题:Objective-c Parse JSON Response

我做了很多读物,但我无法找到与我努力做的事情相近的东西。 我收到了一名JSON的答复,并附有一份<编码>可调用的<>意见>。 用户在<代码>上选择行文时 UITableView 我要赞扬与所展示名称相关的相应“id”价值。 JSON的答复:

{"active":true,"created_at":"2012-05-12T03:04:21Z","description":"Test 1",
"id":11,"name":"This Is A Test","updated_at":"2012-05-12T03:04:21Z"}

因此,我定下了<代码>可调取的,并注明了本是“测试”的名称,而用户选择将第11号作为选择。 在<代码>didSelectRowAtIndexPath功能I能够拉动

UITableViewCell *selectedCell = [self.tableView cellForRowAtIndexPath:indexPath];

NSString *cellText = selectedCell.textLabel.text;

sc.selectedCategory = cellText;

谁会给我这个物体的名称,但我怎么能再次打电话给独裁者,在名字与选定囚室相匹配时,如何获得“id”的价值? 我很抱着目标,但多年来一直在做ava。 任何例子都很好。

提前感谢!

最佳回答

你有一位独裁者。 您需要将ArrayobjectAtIndex(表view index path)作为NSDictionary的标语,然后使用ForKey

如下文:

NSDictionary *selRow = (NSDictionary *)[myArray objectAtIndex:indexPath.row];
NSInteger myID = [[selRow valueForKey@"id"] intValue];
问题回答

暂无回答




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...