开发者

Part of HTML page in UITextView

开发者 https://www.devze.com 2023-04-12 02:59 出处:网络
I\'m trying to open part of html page with help of ASIHttpRequest and NSRange, but it isn\'t working.

I'm trying to open part of html page with help of ASIHttpRequest and NSRange, but it isn't working. My code:

- (void)requestFinished:(ASIHTTPRequest *)request
{
    // Use when fetching text data
    NSLog(@"Loaded");
    NSString *htmlString = [request responseString];
    NSString *string = @"<a>";
    NSRange range = [htmlString rangeOfString:string];
    if (range.location != NSNotFound)
    {
        range.length += range.location;
        range.location = 0;

        string = @"</a>";
        NSRange rangeOpen = [htmlString rangeOfString:string options:NSBackwardsSearch range:range];
        if (rangeOpen.location != NSNotFound)
        {
            range.length -= rangeOpen.location;
            range.location = rangeOpen.location;
            htmlString = [htmlString stringByReplacingCharactersInRange:range withString:@""];
            NSLog(@"Range %@", NSStringFromRange(range));
            NSLog(@"%@", htmlString);
        }
    }
}

It was code for removing tags and I want to transform it. For example: I want to open text between tags in 开发者_StackOverflowUILabel or UITextView


Did you set your delegate on that ASIHTTPRequest to the object where your range checking code lives?

The method you're trying to use is a delegate method, and I can see it declared in the checked-in GitHub repository.

https://github.com/pokeb/asi-http-request/blob/master/Classes/ASIHTTPRequestDelegate.h

0

精彩评论

暂无评论...
验证码 换一张
取 消