Question

I use the URL parser class from Dimitris but i encounter a problem when init object trought initWithURLString:

- (id) initWithURLString:(NSString *)url{
    self = [super init];
    if (self != nil) {
        NSString *string = url;
        NSScanner *scanner = [NSScanner scannerWithString:string];
        [scanner setCharactersToBeSkipped:[NSCharacterSet characterSetWithCharactersInString:@"&?"]];
        NSString *tempString;
        NSMutableArray *vars = [NSMutableArray new];
        //ignore the beginning of the string and skip to the vars
        [scanner scanUpToString:@"?" intoString:nil];
        while ([scanner scanUpToString:@"&" intoString:&tempString]) {
            [vars addObject:[tempString copy]];
        }
        self.variables = vars;
    }
    return self;
}

On line [scanner scanUpToString:@"?" intoString:nil]; i get an error:

[NSURL length]: unrecognized selector sent to instance 0x1f8c2050

How is it possible?

EDIT: maybe you want to know how i call URLParser:

URLParser *urlParser = [[URLParser alloc]initWithURLString:[info valueForKey:UIImagePickerControllerReferenceURL]];

UIImagePickerControllerReferenceURL value is : assets-library://asset/asset.PNG?id=8D2F0449-11A3-4962-9D60-C446831645D7&ext=PNG

Was it helpful?

Solution

You pass a NSURL to initWithURLString, but you should use it with NSString like this:

NSString* urlString = [NSString stringWithFormat:@"%@",[info valueForKey:UIImagePickerControllerReferenceURL]];
URLParser *parser = [[[URLParser alloc] initWithURLString:urlString] autorelease];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top