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

  • Home
  • SEARCH
  • 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 565609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:53:24+00:00 2026-05-13T12:53:24+00:00

I have a pretty standard setup where I have an array in my controller

  • 0

I have a pretty standard setup where I have an array in my controller that I’m binding to an NSTableView. When I add an object to this array with the UI, I add elements by copying the array to a mutable array, adding the contents, then copying it back. I saw this idiom somewhere, but I’m not really sure where, or whether this is actually a sane thing to do. I t works fine on Snow Leopard, but it crashes really badly on Leopard. GDB tells me it happens right at the marked line, where I copy the new array back.

@interface MyAppDelegate : NSObject {

    NSArray * urls;
    //other declarations
}
@property (nonatomic, retain) NSArray *urls;


@implementation MyAppDelegate 

@synthesize urls;

- (void)addThing:(id)sender {

    NSMutableArray *newUrls = [NSMutableArray arrayWithArray: [self urls]];

    [newUrls addObject: newurlimadding];
    [self setUrls: [NSArray arrayWithArray: newUrl]]; 
}

I’m pretty sure I must be doing something boneheaded here. Is there a better way to do this? Why am I crashing?

  • 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-13T12:53:25+00:00Added an answer on May 13, 2026 at 12:53 pm
    NSMutableArray *newUrls = [NSMutableArray arrayWithArray: [self urls]];
    [newUrls addObject: newurlimadding];
    [self setUrls: [NSArray arrayWithArray: newUrl]];
    

    What did you create newUrls for if not to set it as the new value of urls?

    Besides that, there are a couple of things you’re doing wrong:

    1. No model objects. Bindings hates this. Unless your table view exists solely to display the different parts of the URL (scheme, host, path, etc.), each in one column, you’re not giving Bindings what it wants.

      Pay attention to the fields in the Bindings Inspector. Note that there are two: Controller Key and Model Key Path. They’re exactly what they say on their tins: The Controller Key is the key for a property of the controller, which should provide model objects. The Model Key Path is the key path for one or more properties in the model, which usually should provide value objects, such as strings and numbers.

      You probably need to create a model class and make the URL a property of that class. I’d guess that you have other objects, perhaps in parallel arrays, that you can move to properties of the model class. Do that, so that you’re working with Bindings instead of against it.

    2. Not using array accessors. You’re just setting the whole array at once, which is inefficient and may cause display problems (such as selection highlights disappearing). Implement and use array accessors for this array property. Accessorizer can help you here.

    I actually have no idea whether this will fix your crash because you haven’t told us anything about it. You should edit your question to include any exception messages or other crash-describing output, which you’ll find in the Run Log/Debugger Console.

    Also, since the type of urls can be mutable, you should set it to copy, not retain.

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

Sidebar

Ask A Question

Stats

  • Questions 347k
  • Answers 347k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer try this, this is working with hibernate 3.5.1: CriteriaBuilder cb… May 14, 2026 at 6:18 am
  • Editorial Team
    Editorial Team added an answer if you are binding in a template you can use:… May 14, 2026 at 6:18 am
  • Editorial Team
    Editorial Team added an answer Microsoft has included Jquery in their Visual Studio releases (see:… May 14, 2026 at 6:18 am

Related Questions

I have a pretty standard table set-up in a current application using the .NET
I have an apache 2.2 server infront of a tomcat 6 server. using mod_proxy_ajp
I am in the process of setting up a complete web-development environment. For now,
My company has been evaluating Spring MVC to determine if we should use it
OK we are at the end of our rope here, and I’d really appreciate

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.