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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:55:17+00:00 2026-05-23T15:55:17+00:00

I’m seeing a weird behavior and I would need some help with it. In

  • 0

I’m seeing a weird behavior and I would need some help with it.

In structure.h I have:

typedef struct {
    NSString *summary;
    NSArray *legs;
    NSString *copyrights;
    struct polylineSruct overview_polyline;
    struct directionBounds bounds;    
} route;

typedef struct {
    NSArray *routes;
    NSString *status;
} directions;

In structure.m I have:

(directions) a_Function_that_builds_the_struct
{
    directions direct;

    direct.status = @"OK";

    NSMutableArray *routes = [NSMutableArray array];
    for(xxx)
    {
        route routeL;
        routeL.summary = @"1";
        routeL.copyrights = @"2";

        NSValue *boxedroute = [NSValue valueWithBytes:&routeL objCType:@encode(route)];
        [routes addObject:boxedroute];
    }

    direct.routes = routes;

    return direct;
}

in list_itemsViewController.h I have:

implementation XXX:YYY{
    directions directionsLoc;
}
@property (assign) directions directionsLoc;

in list_itemsViewController.h I have:

@synthesize directionsLoc;
....
- (void)viewDidLoad
{
    ....
    self.directionsLoc = a_Function_that_builds_the_struct;
    ....
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [directionsLoc.routes count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ....
    cell.textLabel.text = directionsLoc.status
    return cell;
}

When I start the application I get the list with all the correct rows, if I scroll a little bit for the tableView:cellForRowAtIndexPath: the property directionsLoc is deallocated.

Does anybody have any idea why I get this problem? Is it because I use typedef and the retention is not kept? If I return in the a_Function_that_builds_the_struct and NSArray of directions when the scrolling happens and tableView:cellForRowAtIndexPath: is executed the array had one element as expected but the status and routes elements of the object are zombies.

Any thought on why this happens?

Thank you.

  • 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-23T15:55:18+00:00Added an answer on May 23, 2026 at 3:55 pm

    Structs follow exactly the same rules in Objective-C as C, as it’s a strict superset. So a direct assignment is a shallow copy, and the concept of deallocating just directions directionsLoc; doesn’t really make sense.

    However, you’ve created at least one of the things that is stored within the directions struct — the routes array — as an autoreleased object. Therefore it will be released when next the current autorelease pool is drained, which won’t happen at least until the stack unwinds if you’re not doing anything in that area yourself.

    So the problem isn’t the struct at all, it’s the normal memory management rules, possibly combined with the fact that storing values to a struct looks like Objective-C 2.0 syntax for setting and getting properties but doesn’t involve any sort of method call, so can’t in itself retain or copy.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into

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.