Search code examples
cocoapropertiespngnsdata

In Cocoa get an error saving an image


I was using this code for save a pic after I scaled it:

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

[dataToWrite writeToFile:finalPath atomically:NO];

and it was working fine, but now with new Xcode I get a warning:

Null passed to a callee that requires a non-null argument

What should I put in properties instead of nil?

Thanks a lot for any help


Solution

  • For anyone having the same problem I resolved creating this NSDictionary:

    NSDictionary * dict = [NSDictionary dictionaryWithObject: [NSNumber numberWithFloat:0.5] forKey:NSImageCompressionFactor];
    

    and putting "dict" instead of nil in properties.