缩放后,我使用以下代码保存图片:

NSData *dataToWrite = [rep representationUsingType:NSPNGFileType  properties:nil];

[dataToWrite writeToFile:finalPath atomically:NO];


一切正常,但是现在有了新的Xcode,我得到一个警告:


  Null传递给需要非null参数的被调用方


我应该在属性中添加什么而不是nil?

非常感谢您的帮助

最佳答案

您需要传递NSDictionary,并在NSBitmapImageRep.h中找到字典的可能键(不过您可以传递空字典)

APPKIT_EXTERN NSString* NSImageCompressionMethod;   // TIFF input/output (NSTIFFCompression in NSNumber)
APPKIT_EXTERN NSString* NSImageCompressionFactor;   // TIFF/JPEG input/output (float in NSNumber)
APPKIT_EXTERN NSString* NSImageDitherTransparency;  // GIF output (BOOL in NSNumber)
APPKIT_EXTERN NSString* NSImageRGBColorTable;       // GIF input/output (packed RGB in NSData)
APPKIT_EXTERN NSString* NSImageInterlaced;      // PNG output (BOOL in NSNumber)
APPKIT_EXTERN NSString* NSImageColorSyncProfileData;    // TIFF,GIF input/output (NSData)
APPKIT_EXTERN NSString* NSImageFrameCount;  // GIF input (int in NSNumber) (read-only)
APPKIT_EXTERN NSString* NSImageCurrentFrame;    // GIF input (int in NSNumber)
APPKIT_EXTERN NSString* NSImageCurrentFrameDuration;    // GIF input (float in NSNumber) (read-only)
APPKIT_EXTERN NSString* NSImageLoopCount            ;   // GIF input (int in NSNumber) (read-only)
APPKIT_EXTERN NSString* NSImageGamma                ;   // PNG input/output (float in NSNumber)
APPKIT_EXTERN NSString* NSImageProgressive          ;   // JPEG input/output (BOOL in NSNumber)
APPKIT_EXTERN NSString* NSImageEXIFData             ;   // JPEG input/output (NSDictionary)
APPKIT_EXTERN NSString* NSImageFallbackBackgroundColor  NS_AVAILABLE_MAC(10_5); // JPEG output (NSColor)

09-11 17:20