0

我正在尝试在给定链接的帮助下获取令牌。请通过此链接http://www.stevesaxon.me/posts/2011/window-external-notify-in-ios-uiwebview/

这是什么_data?如何声明?

-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
    if(_data)
    {
        [_data release];
        _data = nil;
    }
}

-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    if(!_data)

    {
        _data = [data mutableCopy];
    }
    else
    {
        [_data appendData:data];
    }
}

-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    if(_data)
    {
        NSString* content = [[NSString alloc] initWithData:_data
                                                  encoding:NSUTF8StringEncoding];

        [_data release];
        _data = nil;

        // prepend the HTML with our custom JavaScript
        content = [ScriptNotify stringByAppendingString:content];

        [_webView loadHTMLString:content baseURL:_url];
    }
}
4

1 回答 1

1

它的NSMutablData对象包含您从对 Web 服务的请求中收到的响应数据

@interface在.h 文件中声明这个

NSMutableData *_data;

@property (nonatomic, retain) NSMutableData *_data;

@synthesize _data;在 .m 文件中的@implementation行后

于 2013-04-26T10:47:38.437 回答