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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:34:20+00:00 2026-05-24T11:34:20+00:00

I have a class returning mutable pathRef’s from class methods like this: + (CGMutablePathRef)roundedRectanglePathInRectangle:(CGRect)rect

  • 0

I have a class returning mutable pathRef’s from class methods like this:

    + (CGMutablePathRef)roundedRectanglePathInRectangle:(CGRect)rect withCornerRadius:(float)radius{

      CGMutablePathRef pathRef = CGPathCreateMutable();

      float x = rect.origin.x;
      float y = rect.origin.y;
      float w = rect.size.width;
      float h = rect.size.height;

      if (radius > w / 2) {
        radius = w / 2;
      }
      if (radius > h / 2) {
        radius = h / 2;
      }

      CGPoint tl = CGPointMake(x + radius, y + radius);
      CGPoint tr = CGPointMake(x + w -radius, y +radius);
      CGPoint br = CGPointMake(x + w -radius, y + h -radius);
      CGPoint bl = CGPointMake(x + radius, y + h -radius);


      CGPathMoveToPoint(pathRef, nil, x, tl.y);
      CGPathAddArc(pathRef, nil, tl.x, tl.y, radius, M_PI, 3*M_PI/2, 0);
      CGPathAddArc(pathRef, nil, tr.x, tr.y, radius, 3*M_PI/2, 0, 0);
      CGPathAddArc(pathRef, nil, br.x, br.y, radius, 0, M_PI/2, 0);
      CGPathAddArc(pathRef, nil, bl.x, bl.y, radius, M_PI/2, M_PI, 0); 

      CGPathAddLineToPoint(pathRef, nil, x, tl.y);



      return pathRef;
      CGPathRelease(pathRef);

    }

now because the last line (release) is after the (return) it is never called and I have a leak. Does anyone have a way to make this CGPath autorelease?

thanks so much 🙂

  • 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-24T11:34:20+00:00Added an answer on May 24, 2026 at 11:34 am

    No, it can’t. You can tell from the “CF” prefix that that type belongs to Core Foundation, which doesn’t have an equivalent to Foundation’s autoRelease. In some cases, there are toll-free bridges between Foundation classes (like NSString) and Core Foundation types (like CFStringRef) that will let you work around this fact, but CFPath and its mutable counterpart are not toll-free-bridged to any Foundation class.

    You’ll have to CFRelease your mutable path after you call the method. You should probably name your method according to memory management conventions that indicate that the caller owns the returned value, and is therefore responsible for releasing it when done.

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

Sidebar

Related Questions

I have class A: public class ClassA<T> Class B derives from A: public class
If I have class names such as left, right, clear and xhtml like <a
I have a generic method (in a non generic class) returning elements. public IEnumerable<T>
I have a class that I have to call one or two methods a
I have a User table defined like this: CREATE TABLE Users( UserId int IDENTITY(1,1)
I have class method that returns a list of employees that I can iterate
I have: class MyClass extends MyClass2 implements Serializable { //... } In MyClass2 is
I have class with internal property: internal virtual StateEnum EnrolmentState { get { ..getter
I have class with a member function that takes a default argument. struct Class
I have class Cab(models.Model): name = models.CharField( max_length=20 ) descr = models.CharField( max_length=2000 )

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.