开发者

Problem getting size of Website Xcode

When i try and compile I come up with a warning that reads initialization makes pointer from integer without a cast. No clue why. I am just trying to get the size of a website.

#import "Lockerz_RedemptionViewController.h"

@implementation Lockerz_RedemptionViewController

-(IBAction)startLoop:(id) sender {
    NSData *dataNew = [NSData dataWithData:[NSData dataWithContentsOfURL:[NSURL
            URLW开发者_StackOverflow社区ithString:@"http://www.google.com/"]]]; 

    NSUInteger *len = [dataNew length];  //error is here

    NSLog(@"%@", len);
}


NSUInteger is just a wrapper for an unsigned int, alter your code to this (i.e. remove the * as it's not a pointer to an object)

NSUInteger len = [dataNew length]; 

Also I think you're going a bit overboard with your initialisation, why not just do

NSData *dataNew = [NSData dataWithContentsOfURL:[NSURL
                   URLWithString:@"http://www.google.com/"]]; 

That should return you an autoreleased object containing the data you need

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜