Compress Image in iOS 12. How will this code be updated? [duplicate]












3
















This question already has an answer here:




  • UIImageJPEGRepresentation has been replaced by instance method UIImage.jpegData(compressionQuality:)

    3 answers




// compressing image(avaImg)before sending it to the server(Parse)

let avaData = UIImageJPEGRepresentation(avaImg.image!, 0.5)
let avaFile = PFFile(name: "ava.jpg", data: avaData!)
user["ava"] = avaFile


When I replace it to the following line as recommended by the notifications I get the error below



let avaData = UIImage.jpegData(avaImg.image!, 0.5)


ERROR: Instance member 'jpegData' cannot be used on type 'UIImage'; did you mean to use a value of this type instead?



I'm a newbie and I followed that on an online course so please baby steps!










share|improve this question















marked as duplicate by rmaddy swift
Users with the  swift badge can single-handedly close swift questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Aug 31 '18 at 13:50


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • let avaData = avaImg.image!.jpegData(avaImg.image!, 0.5)

    – Faris
    Dec 10 '18 at 1:58
















3
















This question already has an answer here:




  • UIImageJPEGRepresentation has been replaced by instance method UIImage.jpegData(compressionQuality:)

    3 answers




// compressing image(avaImg)before sending it to the server(Parse)

let avaData = UIImageJPEGRepresentation(avaImg.image!, 0.5)
let avaFile = PFFile(name: "ava.jpg", data: avaData!)
user["ava"] = avaFile


When I replace it to the following line as recommended by the notifications I get the error below



let avaData = UIImage.jpegData(avaImg.image!, 0.5)


ERROR: Instance member 'jpegData' cannot be used on type 'UIImage'; did you mean to use a value of this type instead?



I'm a newbie and I followed that on an online course so please baby steps!










share|improve this question















marked as duplicate by rmaddy swift
Users with the  swift badge can single-handedly close swift questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Aug 31 '18 at 13:50


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • let avaData = avaImg.image!.jpegData(avaImg.image!, 0.5)

    – Faris
    Dec 10 '18 at 1:58














3












3








3









This question already has an answer here:




  • UIImageJPEGRepresentation has been replaced by instance method UIImage.jpegData(compressionQuality:)

    3 answers




// compressing image(avaImg)before sending it to the server(Parse)

let avaData = UIImageJPEGRepresentation(avaImg.image!, 0.5)
let avaFile = PFFile(name: "ava.jpg", data: avaData!)
user["ava"] = avaFile


When I replace it to the following line as recommended by the notifications I get the error below



let avaData = UIImage.jpegData(avaImg.image!, 0.5)


ERROR: Instance member 'jpegData' cannot be used on type 'UIImage'; did you mean to use a value of this type instead?



I'm a newbie and I followed that on an online course so please baby steps!










share|improve this question

















This question already has an answer here:




  • UIImageJPEGRepresentation has been replaced by instance method UIImage.jpegData(compressionQuality:)

    3 answers




// compressing image(avaImg)before sending it to the server(Parse)

let avaData = UIImageJPEGRepresentation(avaImg.image!, 0.5)
let avaFile = PFFile(name: "ava.jpg", data: avaData!)
user["ava"] = avaFile


When I replace it to the following line as recommended by the notifications I get the error below



let avaData = UIImage.jpegData(avaImg.image!, 0.5)


ERROR: Instance member 'jpegData' cannot be used on type 'UIImage'; did you mean to use a value of this type instead?



I'm a newbie and I followed that on an online course so please baby steps!





This question already has an answer here:




  • UIImageJPEGRepresentation has been replaced by instance method UIImage.jpegData(compressionQuality:)

    3 answers








swift uiimage ios12






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 31 '18 at 13:51









rmaddy

241k27316380




241k27316380










asked Aug 31 '18 at 13:19









Marisabel GonzalezMarisabel Gonzalez

1813




1813




marked as duplicate by rmaddy swift
Users with the  swift badge can single-handedly close swift questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Aug 31 '18 at 13:50


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by rmaddy swift
Users with the  swift badge can single-handedly close swift questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Aug 31 '18 at 13:50


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • let avaData = avaImg.image!.jpegData(avaImg.image!, 0.5)

    – Faris
    Dec 10 '18 at 1:58



















  • let avaData = avaImg.image!.jpegData(avaImg.image!, 0.5)

    – Faris
    Dec 10 '18 at 1:58

















let avaData = avaImg.image!.jpegData(avaImg.image!, 0.5)

– Faris
Dec 10 '18 at 1:58





let avaData = avaImg.image!.jpegData(avaImg.image!, 0.5)

– Faris
Dec 10 '18 at 1:58












1 Answer
1






active

oldest

votes


















11














Do you mean swift 4.2?
Call it like this yourImageObject.jpegData(compressionQuality: 0.5) because function changed to public func jpegData(compressionQuality: CGFloat) -> Data? For more syntax I have a repo your can take a reference with changes from swift 4. https://github.com/alexliubj/Swift-Migration-4.2






share|improve this answer
























  • This API change is from iOS 12, not Swift 4.2.

    – rmaddy
    Aug 31 '18 at 13:52


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









11














Do you mean swift 4.2?
Call it like this yourImageObject.jpegData(compressionQuality: 0.5) because function changed to public func jpegData(compressionQuality: CGFloat) -> Data? For more syntax I have a repo your can take a reference with changes from swift 4. https://github.com/alexliubj/Swift-Migration-4.2






share|improve this answer
























  • This API change is from iOS 12, not Swift 4.2.

    – rmaddy
    Aug 31 '18 at 13:52
















11














Do you mean swift 4.2?
Call it like this yourImageObject.jpegData(compressionQuality: 0.5) because function changed to public func jpegData(compressionQuality: CGFloat) -> Data? For more syntax I have a repo your can take a reference with changes from swift 4. https://github.com/alexliubj/Swift-Migration-4.2






share|improve this answer
























  • This API change is from iOS 12, not Swift 4.2.

    – rmaddy
    Aug 31 '18 at 13:52














11












11








11







Do you mean swift 4.2?
Call it like this yourImageObject.jpegData(compressionQuality: 0.5) because function changed to public func jpegData(compressionQuality: CGFloat) -> Data? For more syntax I have a repo your can take a reference with changes from swift 4. https://github.com/alexliubj/Swift-Migration-4.2






share|improve this answer













Do you mean swift 4.2?
Call it like this yourImageObject.jpegData(compressionQuality: 0.5) because function changed to public func jpegData(compressionQuality: CGFloat) -> Data? For more syntax I have a repo your can take a reference with changes from swift 4. https://github.com/alexliubj/Swift-Migration-4.2







share|improve this answer












share|improve this answer



share|improve this answer










answered Aug 31 '18 at 13:49









Alex LAlex L

20328




20328













  • This API change is from iOS 12, not Swift 4.2.

    – rmaddy
    Aug 31 '18 at 13:52



















  • This API change is from iOS 12, not Swift 4.2.

    – rmaddy
    Aug 31 '18 at 13:52

















This API change is from iOS 12, not Swift 4.2.

– rmaddy
Aug 31 '18 at 13:52





This API change is from iOS 12, not Swift 4.2.

– rmaddy
Aug 31 '18 at 13:52



Popular posts from this blog

List item for chat from Array inside array React Native

Thiostrepton

Caerphilly