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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:47:05+00:00 2026-06-01T06:47:05+00:00

First of all, I’m new to objective-c programming so I’ve probably made some mistakes

  • 0

First of all, I’m new to objective-c programming so I’ve probably made some mistakes in my code.

Here’s what I’ve done : I’ve created a php file with some xml to get values from my MySQL database. Everything goes into a NSArray in objective-C. If I look at the log, everything works fine because it shows my arrays with every MySQL rows and columns like this:

2012-04-02 08:20:14.822 POS[64632:707] (

    {
    CPU = 0;
    TPS = "(null)";
    TVQ = "(null)";
    consigne = 0;
    coutantQuantiteRecue = 0;
    description = "";
    nom = "";
    prixProduit = 0;
    quantiteRecue = 0;
    stock = 0;
},
    {
    CPU = 768;
    TPS = "(null)";
    TVQ = "(null)";
    consigne = 0;
    coutantQuantiteRecue = 0;
    description = "";
    nom = hhh;
    prixProduit = 0;
    quantiteRecue = 0;
    stock = 0;
},

2012-04-02 08:20:14.836 POS[64632:707] The number of rows is:2

The problem is that the only thing I get in my TableView is { in each cell like this:

Table View example image

Here’s my .h :

@interface InventoryManagement : NSObject<NSApplicationDelegate, NSTableViewDataSource>
{
IBOutlet NSTableView* inventoryTable;
NSArray* m_items;

}
-(int)numberOfRowsInTableView:(NSTableView *)inventoryTable;
-(id)tableView:(NSTableView *)inventoryTable objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)rowIndex;
-(void)dealloc;

@property (retain) NSArray* m_items;

@end

And here’s my .m file :

@implementation InventoryManagement

@synthesize m_items;

-(id)init
{
[super init];

NSInteger index = 0;
NSString *urlString = [NSString stringWithFormat:@"http://localhost:8888/php/getProducts.php?index=%d&", index];
m_items = [NSArray arrayWithContentsOfURL:[NSURL URLWithString: urlString]];
NSLog(@"%@", [m_items description]);
[m_items retain];
[inventoryTable reloadData];
return self;
}



-(int)numberOfRowsInTableView:(NSTableView *)inventoryTable
{

NSLog(@"The number of rows in fullResult is:%i", [m_items count]);
return [m_items count];



}

-(id)tableView:(NSTableView *)inventoryTable objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)rowIndex
{

return [m_items objectAtIndex:rowIndex];

}

-(void)dealloc
{
[m_items release];
[super dealloc];
}

@end

My object is well-connected to dataSource and delegate of my TableView. I want those cells to be filled by my database values.

  • 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-01T06:47:07+00:00Added an answer on June 1, 2026 at 6:47 am

    Take a look at Cocoa Bindings for future works. They are great.

    Regarding your question: the problem is in the method

    -(id)tableView:(NSTableView *)inventoryTable objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)rowIndex
    {
    
    return [m_items objectAtIndex:rowIndex];
    
    }
    

    You are returning the whole object, that is:

    {
    CPU = 768;
    TPS = “(null)”;
    TVQ = “(null)”;
    consigne = 0;
    coutantQuantiteRecue = 0;
    description = “”;
    nom = hhh;
    prixProduit = 0;
    quantiteRecue = 0;
    stock = 0; }

    which is a string.
    You have to check the tableColumn variable and return only the right information: e.g. quantiteRecue, CPU, etc..

    The best way to do this is to create a Model class in ObjectiveC which wraps a row of your db. Then your m_items array will contains your Model class, and you can return the right property without parsing every time the string…

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

Sidebar

Related Questions

First of all, I'll admit I am new to this and I've probably just
First of all, let me say I am very new to rails, have been
First of all, I'm not looking for miracle... I know how PHP works and
First of all - I don't have a problem with bad-indentated code and I
First of all, some background: I'm trying to get in a list of integers
First of all there is a question with the same title here on SO
First of all Im new to vb 2010 and so far have enjoyed what
First of all, here's my config: VS2010/Debug/C++ Win32 Project/Vista Home Premium Invoking GetOpenFileName via
First of all, I'm kinda new to the barcode formats and what I do
First of all, I know how to build a Java application. But I have

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.