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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:19:01+00:00 2026-06-03T17:19:01+00:00

I have this property called mySegmented, declared like this .h @property (retain) UISegmentedControl *mySegmented;

  • 0

I have this property called mySegmented, declared like this

.h
@property (retain)  UISegmentedControl *mySegmented;


.m
@synthesize mySegmented = _mySegmented;

then, it was created like this:

self.mySegmented = [self createSegmented];
// createSegmented creates an autoreleased segmented control

My app has 3 different segmented controls. Just one appears at a given time.
At some point of my app, I have to hide one particular segmented control, so, what I do is to build an array of all segmented controls and iterate… this is inside a block.

[UIView animateWithDuration:0.8

             animations:^{

                 NSArray *list = [NSArray arrayWithObjects:
                                  self.mySegmented1,
                                  self.mySegmented2,
                                  self.mySegmented3,
                                  nil];

                 for (UISegmentedControl *oneSeg in list) {
                     [oneSeg setAlpha:0.0f];
                 }

             }];

what happens is: after some time, the app crashes while trying to build this array. I suppose one of the segmented controls is deallocated somehow. No deallocation that I can see in code.

My question is: this array being created is autoreleased. What happens when the block finishes the animation? is a release sent to each member of the array?

If I retain the segmented control after creating it, Xcode complains it will leak.

any clues?

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-03T17:19:02+00:00Added an answer on June 3, 2026 at 5:19 pm

    Please retain like you tried, but make sure to release them in the dealloc method, Xcode should not complain that way.

    Your array is also autoreleased inside the block but that’s fine, the array doesn’t own the references inside of it, the real problem is the segmented controls not being retained by your view controller.

    Let me know how it goes.

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

Sidebar

Related Questions

I have a variable declared like this: @property (nonatomic, retain) NSMutableArray *aInfo; At the
I have an UIButton array like this: @property (nonatomic, retain) IBOutletCollection(UIButton) NSArray *btn_Impact_Collection; and
I have an object with a property called name. This object has a sub
I have this code: ViewController .h @property IBOutlet UITextField *field; ViewController .m @synthesize field;
Do I have this right ... // Reactor.h @property(nonatomic, retain) NSMutableArray *reactorCore; // Reactor.m
I have a combobox inside of my WPF DataGrid. It is created like this:
I have a bunch of classes that each have a property called Sequence. This
I have created a user control which exposes a custom type property called SoftwareItem.
I have a property called IsSecureConnection that is part of my object's interface. This
Lets consider that I have a public property called AvatarSize like the following, public

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.