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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:47:20+00:00 2026-06-09T20:47:20+00:00

I have a NSTableView where items can be added and deleted. Once items have

  • 0

I have a NSTableView where items can be added and deleted. Once items have been added to the table, I would like those items to also show as items for an NSPopUpButton. I tried the addItemsWithTitles: method but it gives me an error.

#import "TableController.h"
#import "Favorites.h"


@interface TableController ()

@property NSMutableArray *array;
@property (weak) IBOutlet NSTableView *tableView;
@property (weak) IBOutlet NSPopUpButton *popButton;

@end


@implementation TableController

- (id)init {
    self = [super init];
    if (self) {
        _array = [[NSMutableArray alloc] init];
    }
    return self;
}

- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
    return [_array count];
}

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
    Favorites *fav = [_array objectAtIndex:row];
    NSString *ident = [tableColumn identifier];
    return [fav valueForKey:ident];
}

- (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
    Favorites *fav = [_array objectAtIndex:row];
    NSString *ident = [tableColumn identifier];
    [fav setValue:object forKey:ident];
}

- (IBAction)add:(id)sender {
    [_array addObject:[[Favorites alloc] init]];
    [_tableView reloadData];
    [_popButton addItemsWithTitles:_array];
}

-(IBAction)delete:(id)sender {
    NSInteger row = [_tableView selectedRow];
    [_tableView abortEditing];
    if (row != -1) {
        [_array removeObjectAtIndex:row];
    }
    [_tableView reloadData];
}

@end

So I tried logging the objectAtIndex:0 for the array and didn’t get a string but received some numbers instead:

Array string is <Favorites: 0x10013e820>

And also for reference my Favorites class is

#import "Favorites.h"

@interface Favorites ()

@property (copy) NSString *location;

@end


@implementation Favorites

- (id)init {
    self = [super init];
    if (self) {
        _location = @"City, State or ZIP";
    }
    return self;
}

@end
  • 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-09T20:47:21+00:00Added an answer on June 9, 2026 at 8:47 pm

    Your array has instances of your class, Favorites, and in your addItemsWithTiles: method you are adding those instances, not some string property of those instances, which is what I presume you want. If you use [_array valueForKey:@”whateverKeyHasYourStrings”] as the argument to addItemsWithTitles: instead of just _array, I think it will work ok.

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

Sidebar

Related Questions

I have an NSTableView which is bound to an NSArrayController. I would like to
I have an NSTableView that contains a number of items. I'd like to implement
I'm facing the following problems: We have meta data for items, each item can
I have an NSTableview which s bound to a NSArrayController. The Table/Arraycontroller contains Core
I have a NSTableView which has cells which can be edited, but when I
I have an NSTableView with multiple selections enabled If I select items and scroll
I have an array of 5 items that is also used as the content
I have an NSTableView with 4 columns. I also have a custom background color
I have an NSTableView that is displaying different views for each cell. How can
How do you bind the NSOutlineView (or NSTableView) so that the items can be

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.