【发布时间】:2016-08-29 12:32:35
【问题描述】:
我有 JSON 字典,但我想获取这个子值。像名称,部分,类别,图像,出生日期。如何获取值,主要是如何通过此位代码获取图像。如何显示图像并将位码转换为图像。请帮忙
我的 Json
[
{
"ID": "1000710017",
"CLASS": "1",
"SECTION": "A",
"NAME": "testing",
"DOB": "123\/123\/999",
"IMAGE": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAB0N0lEQVR4Xu29B4BdR3U+PpJWuytp1btly7ItueAOuGAwNqbYGIMN+BdCgOBACDFOQgkB0sg\.......so big code"
}
]
我的代码
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
NSLog(@"get id %@",self.uid_value);
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://sixthsenseit.com/school/project/ios/profile.php"]];
//create the Method "GET" or "POST"
[request setHTTPMethod:@"POST"];
//Pass The String to server(YOU SHOULD GIVE YOUR PARAMETERS INSTEAD OF MY PARAMETERS)
NSString *userUpdate =[NSString stringWithFormat:@"id=%@&",_uid_value, nil];
//Check The Value what we passed
// NSLog(@"the data Details is =%@", userUpdate);
//Convert the String to Data
NSData *data1 = [userUpdate dataUsingEncoding:NSUTF8StringEncoding];
//Apply the data to the body
[request setHTTPBody:data1];
//Create the response and Error
NSError *err;
NSURLResponse *response;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseData
options:kNilOptions
error:&err];
NSString *resSrt = [[NSString alloc]initWithData:responseData encoding:NSASCIIStringEncoding];
//This is for Response
NSLog(@"got response==%@", resSrt);
if (json)
{
NSArray *results = [json valueForKey:@"NAME"];
}
if(resSrt)
{
NSLog(@"got response");
}
else
{
NSLog(@"faield to connect");
}
}
【问题讨论】:
-
你能出示你的 cdoe
-
您从 web 服务获得格式正确的 IMAGE 链接。更改图片 URL 的格式。
-
您面临的问题是什么?
-
@Anbu.Karthik 请检查编辑我的问题
标签: ios objective-c iphone json web-services