1
我有一個頁面,需要從用戶的郵政編碼,將該數據發送到一個PHP頁面,然後通過JSON檢索數據。此頁面拋出一個錯誤,指出:NSUrl POST錯誤
2011-12-27 15:17:49.919 BusinessManager [3595:20B] *終止應用程序由於未捕獲的異常 'NSInvalidArgumentException',原因是:「* - [ NSConcreteData isFileURL]:無法識別的選擇發送到實例0x4751490'
的代碼是:
- (id)initWithNibName:(NSString *)SearchZip bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:SearchZip bundle:nibBundleOrNil]) {
// Custom initialization
}
return self;
}
- (IBAction) searchzip: (id) sender
{
NSString *post =[NSString stringWithFormat:@"zipcode=%@",zipField.text];
NSString *hostStr = @"https://www.mysite.com/searchzip.php?";
hostStr = [hostStr stringByAppendingString:post];
NSData *dataURL = [NSData dataWithContentsOfURL: [ NSURL URLWithString: hostStr ]];
NSString *jsonData = [[NSString alloc] initWithContentsOfURL:dataURL];
self.zipArray = [jsonData JSONValue];
[jsonData release];
}
- (void)viewDidLoad {
[super viewDidLoad];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [zipArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath {
NSDictionary *infoDictionary = [self.zipArray objectAtIndex:indexPath.row];
static NSString *Prospects = @"agencyname";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Prospects];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:Prospects] autorelease];
}
// setting the text
cell.text = [infoDictionary objectForKey:@"agencyname"];
self.navigationItem.title = @"Zip Search";
// Set up the cell
return cell;
}
我該怎麼辦... – savagenoob 2011-12-27 23:38:23
K它是什麼... – savagenoob 2011-12-27 23:48:06