【发布时间】:2013-04-13 10:57:17
【问题描述】:
我真的是 Xcode 和 Objective-C 的新手...我收到一个 JSON 数组来显示我的 TableView 中的内容:
在我的-viewDidLoad:
[super viewDidLoad];
self.navigationItem.title = @"Kategorien";
NSURL *url = [NSURL URLWithString:@"http://www.visualstudio-teschl.at/apptest/kats.php"];
NSData *jsonData = [NSData dataWithContentsOfURL:url];
if(jsonData != nil)
{
NSError *error = nil;
_kategorien = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error];
}
在我的cellForRowAtIndexPath: 方法中:
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSDictionary *data = [self.kategorien objectAtIndex:indexPath.row];
cell.textLabel.text = [data objectForKey:@"KAT_NAME"];
return cell;
效果很好,并在我的表中显示了我的字符串(键 -> KAT_NAME)。
但是:我怎样才能在我的请求中发送一个字符串?例如,我想在请求中发送“searchnumber = 2”,例如使用 javascript/jquery 的 ajax 请求?
我进行了搜索,但只能找到难以满足我的需求的示例(并且可能是过大的?)...没有像我的请求这样简单的方法和像“sendWithData”这样的广告,还是这种方法与我的完全不同简单的请求?
【问题讨论】:
标签: objective-c json nsurlconnection nsurlrequest