简体   繁体   English

'NSInvalidArgumentException',原因:'-[__ NSCFString encodeString:]:无法识别的选择器已发送到实例

[英]'NSInvalidArgumentException', reason: '-[__NSCFString encodeString:]: unrecognized selector sent to instance

I am making encoding to my NSString value entered in textfield in iOS app. 我正在对在iOS应用程序的文本字段中输入的NSString值进行编码。

This is my code 这是我的代码

NSString *encodedStrr = [myTextFeild.text encodeString:NSUTF8StringEncoding];
NSString *encodedUrlStrr =      [NSString stringWithFormat:
                             @"http://www.damain.com:8080/app/f/query?from=%@",
                             encodedStrr];
NSURL *urlr11 = [NSURL URLWithString: encodedUrlStrr];

I am getting the following error, 我收到以下错误,

    2016-04-19 11:45:46.186 FactualNote[3137:11303] -[__NSCFString  encodeString:]: unrecognized selector sent to instance 0x71c5100
2016-04-19 11:45:46.187 FactualNote[3137:11303] *** Terminating app due     to uncaught exception 'NSInvalidArgumentException', reason: '-  [__NSCFString encodeString:]: unrecognized selector sent to instance 0x71c5100'
*** First throw call stack:
(0x1c93012 0x10d0e7e 0x1d1e4bd 0x1c82bbc 0x1c8294e 0x30ff 0x10e4705     0x182c0 0x18258 0xd9021 0xd957f 0xd86e8 0x47cef 0x47f02 0x25d4a 0x17698 0x1beedf9 0x1beead0 0x1c08bf5 0x1c08962 0x1c39bb6 0x1c38f44 0x1c38e1b 0x1bed7e3 0x1bed668 0x14ffc 0x1eed 0x1e15)

libc++abi.dylib: terminate called throwing an exception libc ++ abi.dylib:终止调用引发异常

I followed this url to encode https://madebymany.com/blog/url-encoding-an-nsstring-on-ios . 我按照此网址编码https://madebymany.com/blog/url-encoding-an-nsstring-on-ios

This is the file I am using and import it in viewController.m. 这是我正在使用的文件,并将其导入viewController.m中。

Desing.h Desing.h

@interface NSString (encode)
    - (NSString *)encodeString:(NSStringEncoding)encoding;
@end

Desing.m 设计

@implementation NSString (encode)
    - (NSString *)encodeString:(NSStringEncoding)encoding
    {
        return (NSString *) CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)self,
                                                            NULL, (CFStringRef)@";/?:@&=$+{}<>,",
                                                            CFStringConvertNSStringEncodingToEncoding(encoding)));
    }  
@end

Following post answer says, this could be memory problem Unrecognized Selector Sent to Instance [NSCFString subarrayWithRange:] . 帖子回答如下,这可能是内存问题, 无法识别的选择器已发送给实例[NSCFString subarrayWithRange:]

How do I come out from this. 我怎么从这出来。

检查您的类别(Desing.m)是否添加到目标中,这可能是原因。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 &#39;NSInvalidArgumentException&#39;,原因:&#39;-[__ NSCFString objectAtIndex:]:无法识别的选择器已发送到实例 - 'NSInvalidArgumentException', reason: '-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 终止应用程序-&#39;NSInvalidArgumentException&#39;,原因:&#39;-[NSCFString objectForKey:]:无法识别的选择器已发送到实例 - Terminating app - 'NSInvalidArgumentException', reason: '-[NSCFString objectForKey:]: unrecognized selector sent to instance UIPickerView NSInvalidArgumentException&#39;,原因:“-[__ NSCFString超级视图]:无法识别的选择器已发送到实例 - UIPickerView NSInvalidArgumentException', reason: '-[__NSCFString superview]: unrecognized selector sent to instance NSInvalidArgumentException - [__ NSCFString unsignedLongLongValue]:发送到实例的无法识别的选择器 - NSInvalidArgumentException -[__NSCFString unsignedLongLongValue]: unrecognized selector sent to instance 由于未捕获的异常&#39;NSInvalidArgumentException&#39;而终止应用程序,原因:-[__ NSCFString方案]:无法识别的选择器已发送到实例 - Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: -[__NSCFString scheme]: unrecognized selector sent to instance 由于未捕获的异常&#39;NSInvalidArgumentException&#39;而终止应用程序,原因:&#39;-[__ NSCFString size]:无法识别的选择器已发送到实例 - Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString size]: unrecognized selector sent to instance &#39;NSInvalidArgumentException&#39;,原因:&#39;-[__NSCFString allKeys]:无法识别的选择器发送到实例 0x7ae2f750&#39; - 'NSInvalidArgumentException', reason: '-[__NSCFString allKeys]: unrecognized selector sent to instance 0x7ae2f750' iOS:“ NSInvalidArgumentException”,原因:“-[__ NSCFString sortedArrayUsingFunction:context:]:无法识别的选择器已发送到实例。 - iOS: 'NSInvalidArgumentException', reason: '-[__NSCFString sortedArrayUsingFunction:context:]: unrecognized selector sent to instance. NSInvalidArgumentException',原因:' - [__ NSCFString isFileURL]:无法识别的选择器发送到实例0x712e450' - NSInvalidArgumentException', reason: '-[__NSCFString isFileURL]: unrecognized selector sent to instance 0x712e450' NSInvalidArgumentException,原因无法识别的选择器发送到实例 - NSInvalidArgumentException, reason unrecognized selector sent to instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM