• 1211纠错


             
    /Users/chenyilong/Dropbox/Xcode/01-modal/01-modal/CYLAppDelegate.m:16:73: No visible @interface for 'UIScreen' declares the selector 'bunds'  //    self.window =[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bunds]];
       
     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
      self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];    
    Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "CYLViewController" nib b    #error:Xcode5根控制器使用xib展示,步骤 ⓵取消mainInterface ⓶右击file's owner对xib进行view-view连线,否则: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "CYLViewController" nib b     
    /Users/chenyilong/Dropbox/Xcode/1211-07-联系人数据存储/CYLAddViewControllerDelegate.h:12:27: Expected a type  #import <Foundation/Foundation.h>
    @protocol CYLAddViewControllerDelegate <NSObject]] > 
    -(
    void)addViewController:(CYLAddViewController *)addView andPerson:(CYLPerson *)person;
    @end
    #import<UIKit/UIKit.h>
    //@class MJHomeViewController;
    @class MJEditViewController, MJPerson;


    @protocol MJEditViewControllerDelegate <NSObject>

    @optional
    //- (void)editViewController:(MJEditViewController *)edit didSaveWithName:(NSString *)name intro:(NSString *)intro;
    - (
    void)editViewController:(MJEditViewController *)edit didSaveWithPerson:(MJPerson *)person;
    @end
    错误地以为协议就不能对其它类进行引用,以为:引用会导致依赖.不理解什么叫”依赖”.”耦合"  
    ⓵/Users/chenyilong/Dropbox/Xcode/1211-07-联系人数据存储/1211-07-联系人数据存储/CYLAddViewController.h:13:38: Pointer to non-const type 'id<CYLAddViewControllerDelegate>' with no explicit ownership
     ⓶/Users/chenyilong/Dropbox/Xcode/1211-07-联系人数据存储/1211-07-联系人数据存储/CYLAddViewController.h:20:1: Property with 'retain (or strong)' attribute must be of object type
    ⓵     id<CYLAddViewControllerDelegate> *_delegate;
     @property (strong,nonatomic) id<CYLAddViewControllerDelegate> *delegate;
    ⓵     id<CYLAddViewControllerDelegate> _delegate;

    @property (strong,nonatomic) id<CYLAddViewControllerDelegate> delegate;

       
      - (IBAction)save:(id)sender {
       
       
     CYLPerson *per = [CYLPerson personWithName:_nameText.text andPhone:_phonetext.text ];
        [
    self addViewController:_delegate andPerson:per];
    //    [self.navigationController pushViewController: animated:<#(BOOL)#>];
        [
    self dismissViewControllerAnimated:YES completion:nil];
    }
         
      - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
       
     static NSString *CellIdentifier = @"Cell";
       
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
       
     if (nil == cell) {
            cell = [[
    UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
        }
    //    for (id per in _person) {
    //       CYLPerson *pers = [CYLPerson personWithName:per.name andPhone:per.phone];
    //    }
       
     CYLPerson *per = _person[indexPath.row];
        cell.
    textLabel.text = per.name;
        cell.
    detailTextLabel.text = per.phone;
        [tableView
     reloadData];
       
     return cell;
    }
         
    不执行协议方法:代理设置不成功. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
       
     CYLAddViewController *add = [[CYLAddViewController alloc ] init];
        add.
    delegate = self;
    //    [_person insert]
    }
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
       
     UINavigationController *nav = segue.destinationViewController;
       
     CYLAddViewController *add =  (CYLAddViewController *) nav.topViewController;
       
     NSLog(@"%@",add);
        add.
    delegate = self;
    }
       
    写入不成功 #pragma mark ---自定义协议实现
    -(void)addViewController:(CYLAddViewController *)addView andPerson:(CYLPerson *)person {
        [
    _person insertObject:person atIndex:0];
        [
    self.tableView reloadData];
    }
         
    2013-12-12 17:12:32.565 1211-07-联系人数据存储[1730:907] 行数设置
    2013-12-12 17:12:32.567 1211-07-
    联系人数据存储[1730:907] *** Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2380.17/UITableView.m:4460
    2013-12-12 17:12:32.568 1211-07-
    联系人数据存储[1730:907] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier myCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
    *** First throw call stack:
    (0x12ac012 0x10d1e7e 0x12abe78 0xd90665 0x2f06c4 0xc877268 0x335f 0x2f98fb 0x2f99cf 0x2e21bb 0x2f2b4b 0x28f2dd 0x10e56b0 0x290ffc0 0x290433c 0x290feaf 0x32e2bd 0x276b56 0x27566f 0x275589 0x2747e4 0x27461e 0x2753d9 0x2782d2 0x32299c 0x26f574 0x26f76f 0x26f905 0xc896ab6 0x278917 0x23c96c 0x23d94b 0x24ecb5 0x24fbeb 0x241698 0x252adf9 0x252aad0 0x1221bf5 0x1221962 0x1252bb6 0x1251f44 0x1251e1b 0x23d17a 0x23effc 0x1e7d 0x1b0b70d)
    libc++abi.dylib: terminate called throwing an exception
    (lldb) 
    错因为⓵或⓶:
    错因⓵


    错因⓶
    未修改系统默认生成的下面这个方法中的内容
    tableView:cellForRowAtIndexPath:
    解决方案一:使用storyboard显示UITableView时,必须为UITableViewCell注册(填写)重用标识符:identifier.必须要与下面方法中的标识符一致.tableView:cellForRowAtIndexPath:
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
    解决方案二:不注册重用标识符,只修改UITableViewController类,系统为其默认生成的方法:将⓵修改为⓶

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        
    static NSString *CellIdentifier = @"myCell";
        
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier  forIndexPath:indexPath];
    //...
    return cell;
    }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        
     static NSString *CellIdentifier = @"myCell";
        
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    //  forIndexPath:indexPath];
    //...
    return cell;
    }  
       

    //本文永久链接,转载请注明出处:http://www.cnblogs.com/ChenYilong/p/3490811.html

    https://www.evernote.com/shard/s227/sh/e1ab6aa0-21d1-4814-a3ee-9577d01f5bed/4310b7bba473d40746defcd3001a2d6f


    作者:
    出处:http://www.cnblogs.com/ChenYilong/(点击RSS订阅)
    本文版权归作者和博客园共有,欢迎转载,
    但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    假期实践
    每周更新学习进度表
    作业三
    作业一
    作业二
    真实感海洋的绘制(一):基于统计学模型的水面模拟方法
    递推方程的求解
    真实感海洋的绘制(二):使用快速傅里叶变换加速波形计算
    "Mathematical Analysis of Algorithms" 阅读心得
    HTML2
  • 原文地址:https://www.cnblogs.com/ChenYilong/p/3490811.html
Copyright © 2020-2023  润新知