self和[self class]

来源:互联网 发布:自助建站 源码 编辑:程序博客网 时间:2024/06/03 00:37

self是实例的指针,[self class]是类的指针,静态方法得用类的指针来调用

- (NSString*) pathForImageURL:(NSString*)imageURL {

   if ([imageURL hasPrefix:@"http://"] || [imageURLhasPrefix:@"https://"] || [imageURLhasPrefix:@"ftp://"])

        return [[selfclass] tmpFilePathForResourceAtURL:imageURL];

   return imageURL;

}



+ (NSString*) tmpFilePathForResourceAtURL:(NSString*)url {

    NSString * fileName = [selffileNameForResourceAtURL:url];

    NSString * path = [selffilePathForTemporaryStorage];

    return [pathstringByAppendingPathComponent:fileName];

}


原创粉丝点击