- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
你好,我是 iPhone 开发新手我想在 xcode4 中显示带有 json 的选择数组到 mysql我在 php 中输出 json 代码 是这样的:
{"data":[{"id":"16","nama":"yes","desk":"test2","gambar":""}]}
我的代码模块是这样的:
list.m
- (void)viewDidLoad
{
AIR = [[NSMutableArray alloc] init];
NSURL *url = [NSURL URLWithString:@"http://192.168.0.169/demo/json/rifle.php"];
NSString *jsonreturn = [[NSString alloc] initWithContentsOfURL:url];
NSLog(jsonreturn);
NSData *jsonData =[jsonreturn dataUsingEncoding:NSUTF8StringEncoding];
NSError *error =nil;
NSDictionary *dict =[[CJSONDeserializer deserializer]deserializeAsDictionary:jsonData error:&error];
if (dict) {
AIR = [[dict objectForKey:@"data"] retain];
}
NSLog(@"Array:%@",AIR);
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [AIR count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
NSDictionary *dict = [AIR objectAtIndex:indexPath.row];
// deklarasi image ambil file gambar didalam field nama
cell.textLabel.text = [dict objectForKey:@"nama"];
// deklarasi image ambil file gambar didalam field desk
cell.detailTextLabel.text = [dict objectForKey:@"desk"];
// deklarasi image ambil file gambar didalam field gambar
UIImage *cellImage =[UIImage imageNamed:[dict objectForKey:@"gambar"]];
cell.imageView.image = cellImage;
return cell;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
subway *mAIR = [[subway alloc] initWithNibName:@"subway" bundle:nil];
[mAIR setTitle:@"AIRGUN DESC DETAIL"];
[self.navigationController pushViewController:mAIR animated:YES];
[mAIR release];
}
subway 是另一个带有 tableView iniNibName subway n 的 ViewController 现在我的问题是如何为选择数组获取 $id(参见 json 代码)如果在 php 中像这样评论
SELECT * FROM data where id="$id"
所以如果我选择列表 NIB,它们将在地铁 NIB 中显示输出
请帮帮我
谢谢
最佳答案
我也这样做,我使用 SBJSON 库:
https://github.com/stig/json-framework/
parsedData 是 JSON 解析后的 NSDicitonary
NSString *responseString = [[NSString alloc] initWithData:downloadedData encoding:NSUTF8StringEncoding];
SBJSON *parser = [SBJSON new];
NSDictionary *parsedData = (NSDictionary *)[parser objectWithString:responseString error: nil];
[responseString release];
[parser release];
您可以在此处找到教程: http://blog.zachwaugh.com/post/309924609/how-to-use-json-in-cocoaobjective-c
关于iphone - 问在xcode4中使用json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9108664/
我有这个gradle命令行,可以完美地工作: /gradle app:testalldevicesproductionenv -Pandroid.testInstrumentationRunnerAr
因此,我使用 NativeBase 作为组件框架来开发 React Native 应用程序。 我正在使用卡片组件。 这是我的代码: render(){ return(
假设我有这样的Kotlin代码: val var1:String? = isVar1Present() val var2:String? = isVar2Present() val var3:Stri
我想要一些有关当前正在使用的程序的指导,如果用户两次输入相同的值,我已经成功创建了一对整数并处理了异常。我一直坚持执行创建对的相同过程,但不是整数,它必须是字符串。 我的一个建议是更改有序对的随机生成
我的 node.js e2e 测试有问题。我想等待 2 个 promise 解决。但由于某种原因,当我使用 Q.all 时,它只是卡住了我的应用程序。我正在使用 kriskowal 的 Q 1.0.0
实际上我已经开发了使用 Hdfs 存储图像的应用程序。现在我想迁移服务器并在新服务器中再次设置 hadoop。我如何将 HDFS(旧服务器)中的图像文件备份到新服务器中的 HDFS? 我尝试使用 Co
我想在GCP上建立一个完全自动化的CI / CD管道。在Cloud Build中,我已经有了一个cloudbuild.yaml,它可以构建Dockerfile并将构建的Docker镜像推送到Conta
我刚刚开始使用Docker,并能够使用Ubuntu 14.03 / LXDE / VNC设置Docker镜像,由于我可以从外部连接到VNC服务器,因此可以很好地工作。 现在,我试图理解Docker的网
我有 Talend Studio Data Intergration 6.2.1。作业导出为 .war,作为 Web 服务在服务器上执行。 我的问题是,有什么方法可以找出哪个应用程序调用我的 ws?
这个问题在这里已经有了答案: Why is super.super.method(); not allowed in Java? (22 个答案) 关闭 9 年前。 我怀疑我想做的事情是否可行。我有
我似乎无法找到正确的方式来表达这一点以进行 Google 搜索。 当我使用 q.all 并且只有一两个失败时(在 Node.js 中)会发生什么。我需要为我使用 Promise 的所有成功实例输入 .
Closed. This question needs to be more focused. It is not currently accepting answers. Learn more。 想
我已经整理了一个宏,它允许我将数据从一张表存档到另一张表,但是我无法让它在之后清除信息。第一列包含我不想清除的数字,现在它只是清除 B 列中的数据。 如果有人可以看看这个,我会非常感激。 'Sub a
我有一个 C# 程序可以从 .txt 文件创建 Excel 文件报告。 它工作完美,但有时(经常)当我打开一个电子表格时,Excel 会打开 2 个电子表格: 1 我保存的文件。1 有一些名为“Pla
为什么不玩 onclick="catch()"?我不明白。 function catch () { alert("safsf"); } ... 最佳答案 catch 是
在 Q 中,有哪些方法可以在 where 子句中使用嵌套查询的结果? 我正在寻找类似于 SQL 语句的内容。 select from food where type_id in ( selec
虽然这段代码可以工作: var promise = function(val) { var _val = val; return setTimeout(function(_val) {
自Mozilla和Google宣布,他们打算将来使用默认设置通过HTTPS激活DNS,并且IETF正式批准了该草案(https://datatracker.ietf.org/wg/doh/about/
OnClickListener 无法与 ScrollView 一起使用,因为“扩展了 Fragment”。我该如何使用它呢?一个例子就足够了。谢谢.. 更新Fragment1.java package
char name[20]=""; char address [50]= ""; do{ printf("Input your name [1..20] : "); scanf("%s
我是一名优秀的程序员,十分优秀!