Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-27-2011, 07:39 PM   #1 (permalink)
Registered Member
 
iphonig's Avatar
 
Join Date: Sep 2009
Location: United States
Posts: 73
iphonig is on a distinguished road
Default UIImageView and UIImage causing crash

Hey All,

I have the following in my program:

Code:
UIGraphicsBeginImageContext(tiltTempView.frame.size);
	[tiltTempView.layer renderInContext:UIGraphicsGetCurrentContext()];
    tiltTempImg = UIGraphicsGetImageFromCurrentImageContext();
	UIGraphicsEndImageContext();
    UIImageJPEGRepresentation(tiltTempImg, 100);
[tiltImage setImage:tiltTempImg];
When I run it my app crashes with bad access. Any ideas as to why?
tiltTempView is a UIView
tiltImage is a UIImageView
tiltTempImg is a UIImage

Thanks!
__________________
Check Out All of Our Apps Here!
iphonig is offline   Reply With Quote
Old 04-27-2011, 09:14 PM   #2 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
JasonR is on a distinguished road
Default

There's no way to tell just from those lines of code, we'd have to know how those objects are being set up. First, you should set NSZombieEnabled. You can find how in your developer documentation. You'll find lots of help using the debugger in the same document.

Then, run it again until the crash, and you should be able to find what line is causing the problem, and a hint to which object is being over-released. Someone can probably help from there.
__________________
My development blog: http://jrinn.com
JasonR is offline   Reply With Quote
Old 04-27-2011, 09:22 PM   #3 (permalink)
Registered Member
 
iphonig's Avatar
 
Join Date: Sep 2009
Location: United States
Posts: 73
iphonig is on a distinguished road
Default

Quote:
Originally Posted by JasonR View Post
There's no way to tell just from those lines of code, we'd have to know how those objects are being set up. First, you should set NSZombieEnabled. You can find how in your developer documentation. You'll find lots of help using the debugger in the same document.

Then, run it again until the crash, and you should be able to find what line is causing the problem, and a hint to which object is being over-released. Someone can probably help from there.
it crashes at
Code:
[tiltImage setImage:tiltTempImg];
the retain count for the tiltImage is 2 and tiltTempImg is 1
__________________
Check Out All of Our Apps Here!
iphonig is offline   Reply With Quote
Old 04-27-2011, 09:26 PM   #4 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
JasonR is on a distinguished road
Default

There's no reliable way to get retain count, so don't trust it. Since you are setting tiltTempImg, it's probably a problem with tiltImage. I bet it's being released and replaced with another object before you are getting to this code.
__________________
My development blog: http://jrinn.com
JasonR is offline   Reply With Quote
Old 04-27-2011, 10:28 PM   #5 (permalink)
Registered Member
 
iphonig's Avatar
 
Join Date: Sep 2009
Location: United States
Posts: 73
iphonig is on a distinguished road
Default

Quote:
Originally Posted by JasonR View Post
There's no reliable way to get retain count, so don't trust it. Since you are setting tiltTempImg, it's probably a problem with tiltImage. I bet it's being released and replaced with another object before you are getting to this code.
i havent done anything else with it. Thats why i am so puzzled haha
__________________
Check Out All of Our Apps Here!
iphonig is offline   Reply With Quote
Old 04-27-2011, 10:57 PM   #6 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
JasonR is on a distinguished road
Default

Well, if you haven't done anything with it, then maybe it's not initialized correctly. How are you setting it up?
__________________
My development blog: http://jrinn.com
JasonR is offline   Reply With Quote
Reply

Bookmarks

Tags
crash, image, photo, uiimage, uiimageview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 342
12 members and 330 guests
dansparrow, iOS.Lover, lorrettaui53, MikaelBartlett, Nobbsy, oztemel, pbart, PlutoPrime, samdanielblr, sledzeppelin, thephotographer, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,120
Posts: 402,897
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:52 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0