• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

iphone - 无法识别的选择器发送到类 0x51e8'

[复制链接]
菜鸟教程小白 发表于 2022-12-12 16:37:43 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

当我尝试将 uitextfeild 值从我的 tableView:didSelectRowAtIndexPath: 方法传递给我的 nsobject 类时,我遇到了这个错误,但是当我单击我为传递 uitextfield 值而编写的 uitableviewcell 时,我收到了下面列出了错误。

//DBAccess.h

    @interface DBAccess : NSObject {

        NSString *receiveCodeText;

    }

    @property (nonatomic, retain) IBOutlet NSString *receiveCodeText;

- (NSMutableArray *) getAllMakes;
    - (void) setPassCodeNSString *)theCode;

//DBAccess.m

//...
//Need to set my string here..
- (void)setPassCodeNSString *)theCode{
    receiveCodeText = theCode;
}
//...
- (NSMutableArray *)getAllMakes{
//...
const char *value = [receiveCodeText cStringUsingEncoding:NSUTF8StringEncoding]; //reciveCodeText is set in RootViewController and passed to value here
    [receiveCodeText release];
    sqlite3_bind_text(statement, 1, value, -1, SQLITE_TRANSIENT);

//....
}

//viewController.m

- (void)tableViewUITableView *)tableView didSelectRowAtIndexPathNSIndexPath *)indexPath {

    searchTableViewController *searchTable = [[searchTableViewController alloc] initWithNibName"searchTableViewController" bundle:nil];

    switch (indexPath.row) {
        case 1: {
            searchTable.editedFieldName = @"Make";
            //Pass code number over to DBAccess class
            [DBAccess setPassCode:codeText.text];
        } break;
        case 2: {
            searchTable.editedFieldName = @"Mod";
        } break;
        case 3: {
            searchTable.editedFieldName = @"Method";
        } break;
    }

    [self.navigationController pushViewController:searchTable animated:YES];
    [searchTable release];
}

这就是我遇到的错误。

> 2011-06-13 13:05:33.433
> Code1.6[1318:207] +[DBAccess
> setPassCode:]: unrecognized selector
> sent to class 0x51e8 2011-06-13
> 13:05:33.477 Code1.6[1318:207] ***
> Terminating app due to uncaught
> exception
> 'NSInvalidArgumentException', reason:
> '+[DBAccess setPassCode:]:
> unrecognized selector sent to class
> 0x51e8'
> *** Call stack at first throw: (  0   CoreFoundation                     
> 0x00e45be9 __exceptionPreprocess + 185
>   1   libobjc.A.dylib                  
> 0x00f9a5c2 objc_exception_throw + 47
>   2   CoreFoundation                   
> 0x00e477bb +[NSObject(NSObject)
> doesNotRecognizeSelector:] + 187  3  
> CoreFoundation                     
> 0x00db7366 ___forwarding___ + 966     4  
> CoreFoundation                     
> 0x00db6f22 _CF_forwarding_prep_0 + 50
>   5   Code1.6                       
> 0x000028ff -[RootViewController
> tableView:didSelectRowAtIndexPath:] +
> 253   6   UIKit                        
> 0x00331794 -[UITableView
> _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:]
> + 1140    7   UIKit                               0x00327d50 -[UITableView
> _userSelectRowAtPendingSelectionIndexPath:]
> + 219     8   Foundation                          0x0003a7f6 __NSFireDelayedPerform +
> 441   9   CoreFoundation               
> 0x00e26fe3

> __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
> + 19  10  CoreFoundation                      0x00e28594 __CFRunLoopDoTimer + 1220
>   11  CoreFoundation                   
> 0x00d84cc9 __CFRunLoopRun + 1817  12 
> CoreFoundation                     
> 0x00d84240 CFRunLoopRunSpecific + 208
>   13  CoreFoundation                   
> 0x00d84161 CFRunLoopRunInMode + 97    14
> GraphicsServices                   
> 0x016e7268 GSEventRunModal + 217  15 
> GraphicsServices                   
> 0x016e732d GSEventRun + 115   16  UIKit
> 0x002ca42e UIApplicationMain + 1160
>   17  Code1.6                       
> 0x0000230c main + 102     18  Code1.6    
> 0x0000229d start + 53 ) terminate
> called after throwing an instance of
> 'NSException'



Best Answer-推荐答案


setPassCode 似乎是一个类实例方法而不是静态方法,但您试图将其作为静态方法访问,您必须像这样声明您的方法才能使其成为静态方法

+(void)setPassCode....

您的程序崩溃是因为您在类本身而不是类的实例上调用该方法.. 希望这会有所帮助

关于iphone - 无法识别的选择器发送到类 0x51e8',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6325945/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap