0

CustomCell 内のアイテムを表示できません。私が名前を付ければnamesurnameすべてがうまくいきます。しかし、surname fieldそれらを取り外してフィールドにまとめると、null. のせいだと思いspace characterます。出発フィールドでも同じことが起こります。これをどのように解決するかわかりません。私はIOS開発の初心者です。

AppDelegate.m:

-(void)chackDB{

    NSFileManager *fileManager = [NSFileManager defaultManager];

    NSString *docPath = [[self documentsDirectory]stringByAppendingPathComponent:@"drList.plist"];

    if([fileManager fileExistsAtPath:docPath]) return;

    NSString *sourcePath = [[NSBundle mainBundle]
                            pathForResource:@"drList" ofType:@"plist"];
    NSError *err=nil;
    [fileManager copyItemAtPath:sourcePath toPath:docPath error:&err];

    if(err){

        NSLog(@"hata: %@",[err description]);
    }
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [self chackDB];

これが私のplistです:

    <array>
        <dict>
            <key>depart</key>
            <string>Plastic Surgery</string>
            <key>name</key>
            <string>John Smith</string>
        </dict>
    </array>

私のコード:

    - (UITableViewCell*)tableView:(UITableView *)tableView
        cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"cellid";

    CustomCell *cell = (CustomCell*)[tableView dequeueReusableCellWithIdentifier:cellID];

    if (cell == nil)
    {
        cell = (CustomCell*)[[[NSBundle mainBundle]
                              loadNibNamed:@"CustomCell" owner:nil options:nil]
                             lastObject];
    }

    // customization
    NSDictionary *d = [self.dataList objectAtIndex:indexPath.row];

    cell.nameLabel.text = [NSString stringWithFormat:@"%@",
                           [d objectForKey:@"name"]];

    cell.departLabel.text = [NSString stringWithFormat:@"%@",
                           [d objectForKey:@"depart"]];


    cell.indexPath = indexPath;


    return cell;
}

行を選択したときの DetailViewController は次のとおりです。

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    self.name.text = [NSString stringWithFormat:@"Name: %@",[self.userInfo objectForKey:@"name"]];
    self.depart.text = [NSString stringWithFormat:@"Department: %@",[self.userInfo objectForKey:@"depart"]];

}
4

0 に答える 0