如题,如果有一个logo.jpg的文件,我在获得这个图片文件的指针的同时想得到这个图片文件的大小(B或者KB),应该怎么做啊?NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"logo"ofType:@"jpg"];
UIImage *image = [[UIImage alloc] initWithContentsOfFile:imagePath];
我只有22分,就给20分吧,虽然少点,诚意在。谢谢了!

解决方案 »

  1.   


    NSFileManager * filemanager = [[NSFileManager alloc]init];
    if([filemanager fileExistsAtPath:[self getCompletePath] isDirectory:&isDirectory]){
         NSDictionary * attributes = [filemanager attributesOfItemAtPath:[self getCompletePath] error:nil];
    // file size
         NSNumber *theFileSize;
         if (theFileSize = [attributes objectForKey:NSFileSize])_fileSize= [theFileSize intValue];
    }ORIETechhttp://www.orietech.com
      

  2.   

    l楼上说的是对文件处理,我这里是uiimage对象,已经解决了。我用了UIImageJPEGRepresentation和length方法处理。效果很好。
      

  3.   

    你好,这个用过,
    UIImage或者UIImageView有个size的属性,可以获取的。