Ios NSTaggedPointerString到无符号整数

Ios NSTaggedPointerString到无符号整数,ios,objective-c,casting,unsigned-integer,openurl,Ios,Objective C,Casting,Unsigned Integer,Openurl,我试图将URL查询组件解析为无符号整数。当尝试将从URL提取的字符串(一个NSTaggedPointerString)强制转换为无符号整数时,程序会因以下原因崩溃: 由于未捕获异常而终止应用程序 “NSInvalidArgumentException”,原因:'-[NSTaggedPointerString unsignedIntegerValue]:发送到实例XXX的选择器无法识别 我的AppDelegate中的我的应用程序:openURL:options:method如下所示: - (BOO

我试图将URL查询组件解析为无符号整数。当尝试将从URL提取的字符串(一个NSTaggedPointerString)强制转换为无符号整数时,程序会因以下原因崩溃:

由于未捕获异常而终止应用程序 “NSInvalidArgumentException”,原因:'-[NSTaggedPointerString unsignedIntegerValue]:发送到实例XXX的选择器无法识别

我的AppDelegate中的我的应用程序:openURL:options:method如下所示:

- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {

    NSURLComponents *components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO];

    NSMutableDictionary *queryItemDict = [NSMutableDictionary dictionaryWithCapacity:components.queryItems.count];

    for (NSURLQueryItem *queryItem in components.queryItems) {
        [queryItemDict setObject:queryItem.value forKey:queryItem.name];
    }

    if ([[queryItemDict allKeys] containsObject:@"selectedSection"]) {
        NSUInteger selectedSection = 0;
        NSLog(@"%@",[[queryItemDict objectForKey:@"selectedSection"] class]);
        selectedSection = [[queryItemDict objectForKey:@"selectedSection"] unsignedIntegerValue];
    }


    return YES;
}
-(BOOL)应用程序:(UIApplication*)应用程序
openURL:(NSURL*)url
选项:(NSDictionary*)选项{
NSURLComponents*components=[NSURLComponents components SwithUrl:url resolvingAgainstBaseURL:NO];
NSMutableDictionary*queryItemDict=[NSMutableDictionary dictionaryWithCapacity:components.queryItems.count];
用于(组件中的NSURLQueryItem*queryItem.queryItems){
[queryItemDict setObject:queryItem.value forKey:queryItem.name];
}
如果([[queryItemDict allKeys]包含对象:@“selectedSection”]){
nsu整数selectedSection=0;
NSLog(@“%@,[[queryItemDict objectForKey:@“selectedSection”]class]);
selectedSection=[[queryItemDict objectForKey:@“selectedSection”]UnsignedItemValue];
}
返回YES;
}
我已经在一个空白的iosxcode项目中测试了它,并像这样注册了URL方案“test”

我的测试url是
test://selectedSection=0


如果需要的话,我可以上传示例项目,但以上两个步骤是复制所需的全部步骤。我没有正确地将NSString转换为无符号整数吗?

您看过
NSString
的文档了吗?没有
unsignedIntegerValue
方法。谢谢。我能够将正的
NSInteger
转换为
NSInteger
<代码>selectedSection=(NSInteger)[[queryItemDict objectForKey:@“selectedSection”]integerValue]您看过
NSString
的文档了吗?没有
unsignedIntegerValue
方法。谢谢。我能够将正的
NSInteger
转换为
NSInteger
<代码>selectedSection=(NSInteger)[[queryItemDict objectForKey:@“selectedSection”]integerValue]