English 中文(简体)
用户(这一类别在关键数据来源方面不合规关键价值编码)
原标题:iOS app (this class is not key value coding-compliant for the key dataSource)

I mMaking an Pierre, and I m working at this TableViewController, but when test, I have this mis, and I t do with this:

2012-01-13 13:45:32.947 HandHistory Reviews[3422:707] *** 
Terminating app due to uncaught exception  NSUnknownKeyException , 
reason:  [<SessionsTableViewController 0x191cb0> setValue:forUndefinedKey:]: 
this class is not key value coding-compliant for the key dataSource. 

没有人会想?

这是我的开庭记录:

#import "SessionsTableViewController.h"
#import "Session.h"

@interface SessionsTableViewController()

@property (nonatomic, copy) NSArray *sessions;

@end

@implementation SessionsTableViewController

@synthesize sessions = _sessions;

#pragma mark - View lifecycle

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

    NSMutableArray *sessions = [[NSMutableArray alloc] init];

    // Looking for files
    // Finding the Documents directory
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *path = [paths objectAtIndex:0];
    NSArray *directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:nil];

    // Looping through each file in the directory
    for (NSString *file in directoryContent)
    {
        NSString *contents = [NSString stringWithContentsOfFile:[[paths objectAtIndex:0] stringByAppendingPathComponent:file] encoding:NSUTF8StringEncoding error:nil];

        Session *session = [[Session alloc] initWithName:file andContents:contents];

        [sessions addObject:session];
    }

    self.sessions = sessions;
}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.sessions count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Session Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    //cell.textLabel.text = [[self.sessions objectAtIndex:indexPath.row] name];
    //cell.detailTextLabel.text = [[NSString alloc] initWithFormat:@"%d hands", 10];

    return cell;
}



#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Navigation logic may go here. Create and push another view controller.
    /*
     <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
     // ...
     // Pass the selected object to the new view controller.
     [self.navigationController pushViewController:detailViewController animated:YES];
     */
}

@end
最佳回答

它不正确地看着你把电线放在接口建筑中。 随函附上一份名为<编码>的数据/编码>的散页(<>)。 当我假定你在<代码>上有一席之地时,你可能希望以另一轮方式这样做。 SessionsTableViewController。

因此,你需要把你认为的<代码>数据财产附于您的<代码>。 电话:(如果是的话,可能是“File s Owner”,而不是另一轮。

问题回答

这种错误通常发生在没有适当连接点时。 在我的案件中,检查点连接总是会解决。

检查,确保贴上标签模块中的错误标识(按级调整)。 该公司的指定检查员就是这样做的。

通常,如果你没有贴上“现时......”的贴切入标签,那么你就没有被指定为模块。 但是,如果你在此具体指明了一件事,则贵组织项目的任何其它用具都可以获得,在你试图掌握其他用具时,就给你这个主题错误的信息。

这是我的问题......





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签