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 7702565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:15:21+00:00 2026-05-31T23:15:21+00:00

Ok, I’ve an array of dummy objects containing property cgpath. This is called darkPathArray

  • 0

Ok, I’ve an array of dummy objects containing property cgpath. This is called darkPathArray property in my UIView.

When I draw them one after another I found an interesting thing to happen. I got EXC_BAD_ACCESS on CGContextAddPath(context,ppath.path); (ppath.path throws that) when running on iOS 5 sim/device. But When I put a NSLog call in front of CGContextAddPath, it works correctly. And this is, because it’s significantly slown down.

So the problem is in the frequency of -drawRect callings. That’s ok, I could fake it ’till I’d make it, but that’s not the way professional works.

Therefore I’m asking why is this happening?

-(void)drawRect:(CGRect)r
{
    // Get the graphics context and clear it
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextClearRect(context, self.bounds);

    [[UIColor whiteColor] set];
    UIRectFill ([self bounds]);

    // Draw every single section as a path
    for (ShopSection *section in self.shopSectionsArray) {
        // Draw the walls
        [section.darkColor setFill];

        for (MMPath *ppath in section.darkPathArray) {
            CGContextAddPath(context,ppath.path);
            CGContextDrawPath(context, kCGPathFill);
        }
    }
}

Edit:
ARC enabled

MMPaths are not changing

EXC_BAD_ACCESS is responding to bad section object / dunno why (they’re stored safely in the array)

Superview: UIScrollView
Layer: CATiledLayer

The problem with bad access occurs when the content is rapidly redrawn – on fast device/simulator or when wildly scrolling and zooming.

Edit2:
I think I got it! The problem is that CATiledLayer draws on backround threads, so it somehow catches it’s tail. Have anyone an idea how to fix that? What is the best approach for that? What am I doing wrong?

  • 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-05-31T23:15:22+00:00Added an answer on May 31, 2026 at 11:15 pm

    I finally changed my mind and used the CAShapeLayer instead of my MMPath (NSObject with CGPath property). Then using CGRectIntersectsRect, I’ve managed to get rid of that multithreading bug.
    It also mean an optimalization as only the appropriate shapes are drawn in each rect.

    So that’s how multiple shapes in CATiledLayer shall be drawn:

    -(void)drawRect:(CGRect)rect
    {
    // Get the graphics context and clear it
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextClearRect(context, self.bounds);
    
    [[UIColor whiteColor] set];
    UIRectFill ([self bounds]);
    
    // Draw every single section as a path
    for (ShopSection *section in self.shopSectionsArray) {
    
        CAShapeLayer *s = section.wallsShapeLayer;
        // Draw the walls
        if ( CGRectIntersectsRect(rect, s.frame ) )
        {
            // Rasterising before rendering enhances the performance a bit
            s.shouldRasterize = YES;
            [s renderInContext:context];
        }
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I'm making a simple page using Google Maps API 3. My first. One marker

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.