안녕하세요, 저는 Cocoa Development를 처음 사용하고 있으며, 내가 잘못했는지 파악하려고합니다. 필자는 touchJSON을 사용하여 Xcode에서 mySQL 데이터베이스로 tableView를 채우는 (tutorial)을 따랐습니다.touchJSON에서 NSInvalidException NSNull isEqualtoString :
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[NSNull isEqualToString:]: unrecognized selector sent to
instance 0x1469cd8'
이 PHP 코드 (데이터베이스)와 함께 할 수있는 뭔가가 있다면 난 정말 모르겠어요 : 나는 응용 프로그램의 모든 것이 잘 작동 실행,하지만 난있는 tableView를 아래로 스크롤 할 때 나는 NSInvalidExeption
오류가 발생하는 경우 또는 Xcode의 코드. 이미 나는이 새로운 해요 말했듯이
#import "GentDataView.h"
#import "CJSONDeserializer.h"
#import "GentDetailCell.h"
@implementation GentDataView
@synthesize rows, tableview;
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *url = [NSURL URLWithString:@"http://localhost:8888/example3.php"]; //URL Modification
NSString *jsonreturn = [[NSString alloc] initWithContentsOfURL:url]; // Pulls the URL
// NSLog(jsonreturn); // Look at the console and you can see what the restults are
NSData *jsonData = [jsonreturn dataUsingEncoding:NSUTF32BigEndianStringEncoding];
NSError *error = nil;
// In "real" code you should surround this with try and catch
NSDictionary * dict = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error];
if (dict)
{
rows = [dict objectForKey:@"tblWebData"];
}
NSLog(@"Array: %@",rows);
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [rows count];
}
// Customize the appearance of table view cells.
- (GentDetailCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
GentDetailCell *cell = (GentDetailCell *) [tableview dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[GentDetailCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
// Configure the cell.
NSSortDescriptor *sorteerDiscriptor = [[NSSortDescriptor alloc] initWithKey:@"id" ascending:NO];
rows = [rows sortedArrayUsingDescriptors:[NSArray arrayWithObject:sorteerDiscriptor]];
NSDictionary *dict = [rows objectAtIndex: indexPath.row];
cell.Naam.text = [dict objectForKey:@"Naam"];
cell.Plaats.text = [dict objectForKey:@"Plaats"];
cell.Maand.text = [dict objectForKey:@"Maand"];
cell.Locatie.text = [dict objectForKey:@"Locatie"];
cell.imageView.image = [NSURL URLWithString:@"http://www.iconarchive.com/show/flags-icons-by-iconscity/belgium-icon.html"];
//cell.textLabel.text = [dict objectForKey:@"post_title"];
//cell.detailTextLabel.text = [dict objectForKey:@"post_content"];
//tableView.backgroundColor = [UIColor cyanColor];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 125;
}
@end
, 그래서 어떤 도움은 매우 매우 환영받을 것이다 :이 엑스 코드에서 내 코드
<?php
$link = mysql_pconnect("localhost", "root", "root") or die("Could not connect");
mysql_select_db("PartyON") or die("Could not select database");
$arr = array();
$rs = mysql_query("SELECT id, Maand, Naam, Locatie, Plaats FROM tblWebData");
while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
}
echo '{"tblWebData":'.json_encode($arr).'}';
?>
입니다 :
이 내 PHP 코드입니다 ! 나는이 문제를 며칠 동안 파악하려고 노력하고 있지만 정확한 답이나 해결책을 찾을 수없는 것 같습니다!
미리 감사드립니다. 나는 당신의 데이터베이스에서오고 개체 중 하나 같은데요