iphone - 无法识别的选择器发送到类 0x51e8'
<p><p>当我尝试将 uitextfeild 值从我的 tableView:didSelectRowAtIndexPath: 方法传递给我的 nsobject 类时,我遇到了这个错误,但是当我单击我为传递 uitextfield 值而编写的 uitableviewcell 时,我收到了下面列出了错误。</p>
<p>//DBAccess.h</p>
<pre><code> @interface DBAccess : NSObject {
NSString *receiveCodeText;
}
@property (nonatomic, retain) IBOutlet NSString *receiveCodeText;
- (NSMutableArray *) getAllMakes;
- (void) setPassCode:(NSString *)theCode;
</code></pre>
<p>//DBAccess.m</p>
<pre><code>//...
//Need to set my string here..
- (void)setPassCode:(NSString *)theCode{
receiveCodeText = theCode;
}
//...
- (NSMutableArray *)getAllMakes{
//...
const char *value = ; //reciveCodeText is set in RootViewController and passed to value here
;
sqlite3_bind_text(statement, 1, value, -1, SQLITE_TRANSIENT);
//....
}
</code></pre>
<p>//viewController.m</p>
<pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
searchTableViewController *searchTable = [ initWithNibName:@"searchTableViewController" bundle:nil];
switch (indexPath.row) {
case 1: {
searchTable.editedFieldName = @"Make";
//Pass code number over to DBAccess class
;
} break;
case 2: {
searchTable.editedFieldName = @"Mod";
} break;
case 3: {
searchTable.editedFieldName = @"Method";
} break;
}
;
;
}
</code></pre>
<p>这就是我遇到的错误。</p>
<pre><code>> 2011-06-13 13:05:33.433
> Code1.6 +[DBAccess
> setPassCode:]: unrecognized selector
> sent to class 0x51e8 2011-06-13
> 13:05:33.477 Code1.6 ***
> Terminating app due to uncaught
> exception
> 'NSInvalidArgumentException', reason:
> '+:
> 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:] + 1873
> 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__
> + 1910CoreFoundation 0x00e28594 __CFRunLoopDoTimer + 1220
> 11CoreFoundation
> 0x00d84cc9 __CFRunLoopRun + 181712
> CoreFoundation
> 0x00d84240 CFRunLoopRunSpecific + 208
> 13CoreFoundation
> 0x00d84161 CFRunLoopRunInMode + 97 14
> GraphicsServices
> 0x016e7268 GSEventRunModal + 21715
> GraphicsServices
> 0x016e732d GSEventRun + 115 16UIKit
> 0x002ca42e UIApplicationMain + 1160
> 17Code1.6
> 0x0000230c main + 102 18Code1.6
> 0x0000229d start + 53 ) terminate
> called after throwing an instance of
> 'NSException'
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>setPassCode 似乎是一个类实例方法而不是静态方法,但您试图将其作为静态方法访问,您必须像这样声明您的方法才能使其成为静态方法</p>
<pre><code>+(void)setPassCode....
</code></pre>
<p>您的程序崩溃是因为您在类本身而不是类的实例上调用该方法..
希望这会有所帮助</p></p>
<p style="font-size: 20px;">关于iphone - 无法识别的选择器发送到类 0x51e8',我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/6325945/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/6325945/
</a>
</p>
页:
[1]