0

コンソールに出力するNSURLと、次のようになります 。

<AVURLAsset: 0x170232800, URL = assets-library://asset/asset.MOV?id=426C5913-86CF-4476-2DB6-6A9AAC626AF4&ext=MOV>

この URL の id 部分に到達する適切な方法は何ですか? 目標は、文字列を持つこと426C5913-86CF-4476-2DB6-6A9AAC626AF4です。

4

2 に答える 2

3

次のようなものを使用できます。

NSURL *url = [[NSURL alloc] initWithString:@"assets-library://asset/asset.MOV?id=426C5913-86CF-4476-2DB6-6A9AAC626AF4&ext=MOV"];
NSArray *components = [[url query] componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"=&"]];
NSMutableDictionary *params = [NSMutableDictionary dictionary];
for (NSUInteger idx = 1; idx < components.count; idx+=2) {
    params[components[idx - 1]] = components[idx];
}

NSLog(@"params[@id] = %@", params[@"id"]);

この目的のために、NSURL のカテゴリを作成することをお勧めします。

于 2013-10-19T10:51:41.570 に答える
0

次から始めます。

NSURL *urlAddress = [NSURL URLWithString:yourAddressString];

それで:

[urlAddress scheme] gives the Scheme;
[urlAddress host] gives the host
[urlAddress path], [urlAddress relativePath], [urlAddress query], [urlAddress fragment] or [urlAddress parameterString] gives the correspondent parts of your urlAddress
于 2013-10-19T10:52:01.707 に答える