Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9058727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:47:45+00:00 2026-06-16T14:47:45+00:00

Good evening, I’m just about finished with this new app that I made and

  • 0

Good evening,

I’m just about finished with this new app that I made and I was doing some final tests on it before I submitted it to the app store, but something came up that really stumped me. For one of my view controllers I’m using a UITableView and so I implemented the

 -(UIView*) tableView:(UITableView*) tableView viewForHeaderInSection:(NSInteger) section

method of the UITableViewDelegate protocol so that I could provide my own custom view for the header. (Yes, I did also conformed to the UITableViewDataSource protocol and provided all necessary methods for it)

So I wrote my own UIView class and implemented the drawRect: method to draw my own custom view. When I run this in both the iPad 6.0 and iPhone 6.0 simulators, it runs perfectly fine.

However, when I plug up my own iOS device ( running iOS 6) it crashes and throws EXC_BAD_ACCESS.

I did some breakpoints and found out that when running the app on my real device, the code only gets executed up to here:

    // This code is the beginning of my drawRect method for my custom view
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGColorRef lightBlue = [UIColor colorWithRed:72.0/255.0
                                      green:121.0/255.0      
                                      blue:201.0/255.0 alpha:1].CGColor;

    CGColorRef cream = [UIColor colorWithRed:235.0/255.0 
                            green:235.0/255.0
                            blue:235.0/255.0 alpha:1].CGColor;
    CGContextSetFillColorWithColor(context,cream);
    CGContextFillRect(context, _paperBox); 
     // the _paperBox variable was defined earlier as CGRect _paperBox
     // the _paperBox variable was given a value in the -(void)layoutSubviews method

    CGColorRef shadow = [UIColor colorWithWhite:.5 alpha:.5].CGColor;
    CGContextSetShadowWithColor(context, CGSizeMake(0,3), 2, shadow);
    CGContextSetFillColorWithColor(context, lightBlue);

    // and later on I setup some code to draw a linear gradient:

    NSArray colors = [NSArray arrayWithObjects:(__bridge id) lightBlue,
                                                 (__bridge id) cream,
                                                 nil];

The EXC_BAD_ACCESS happens right at that last line. Why does this only happen when running on a real iOS device and not on the simulators?

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T14:47:46+00:00Added an answer on June 16, 2026 at 2:47 pm

    I found out the answer to my question, hopefully anyone else reading this that was having the same troubles will find this response helpful. Due to the release of ARC and the new __bridge modifiers, my old casts to:

        (__bridge id) 
    

    on each CGColorRef weren’t technically “correct” with the new ARC terms, and I’m not too familiar with the new __bridge concepts so what I did that fixed it was not to make a CGColorRef for each UIColor, but instead cast the CGColor property of each UIColor to id in the array like so:

        NSArray* array = [NSArray arrayWithObjects:
        (id)[UIColor whiteColor]CGColor],
        (id)[[UIColor colorWithRed:235.0/255.0 
        green:235.0/255.0 blue:235.0/255.0]CGColor],nil];
    

    This seemed to do the trick for me. However, I do recommend for everyone who isn’t already familiar with the new __bridge modifiers to learn them when using ARC ( including myself).

    Thanks everyone!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good evening, In my app that I'm currently developing, I have a class that
Good Evening, I am pretty new to Unix so maybe this mini project is
Good evening everyone! I am working on learning some java and I have made
Good evening, I'm having an issue with Masonry. This is all my relevant code:
Good evening all, I've been working on an MD5 tool in C# that takes
Good evening everyone. I am puzzling over the oddity that the jQuery Marquee plugin
Good evening, I just started playing with Microsoft.Contracts (latest version) and plugging it on
Good evening, I am working on a program where some application config info is
Good evening! Been searching all over, and I'm afraid I've just got something completely
Good evening, i hope you can help me with this problem, as I'm struggling

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.