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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:40:22+00:00 2026-05-23T10:40:22+00:00

So in my model I have the following code… I am successfully able to

  • 0

So in my model I have the following code… I am successfully able to return each individual value. I want to know how am I able to return the entire speakerTable []… Maybe some advice. Thanks!

typedef struct {
    NSUInteger speakerID;
    NSString * speakerName;
    NSString * speakerPosition;
    NSString * speakerCompany;
} SpeakerEntry;

static const SpeakerEntry speakerTable [] = 
{
    {0, @"name", @"position", @"company"},
    {1, @"name", @"position", @"company"},
    {-1, nil, nil, nil}
};

This works correctly…

-(NSString *) stringSpeakerCompanyForId:(NSUInteger) identifier{
NSString * returnString = nil;
if ([self helpCount] > identifier) {
    returnString = speakerTable[identifier].speakerCompany;
}
return returnString;

}

This does not work at all..

-(id) getSpeaker{
//if ([speakerTable[0].speakerName isKindOfClass:[NSString class]])
//  NSLog(@"YES");
NSArray * myArray3 = [NSArray arrayWithArray:speakerTable];
return myArray3;

}

  • 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-23T10:40:22+00:00Added an answer on May 23, 2026 at 10:40 am

    arrayWithArray expects an NSArray, not a C array.

    The first one works because you are using it like a C array.

    Alternatively – don’t use a struct, use an object instead:

    Create a class called Speaker.

    In Speaker.h

    @interface Speaker : NSObject {}
    
    @property (nonatomic, assign) NSUinteger id;
    @property (nonatomic, copy) NSString name;
    @property (nonatomic, copy) NSString position;
    @property (nonatomic, copy) NSString company;
    
    - (void)initWithId:(NSUInteger)anId name:(NSString *)aName position:(NSString *)aPosition company:(NSString *)aCompany;
    
    @end
    

    in Speaker.m

    #import "Speaker.h"
    
    @implementation Speaker
    
    @synthesize id, name, position, company;
    
    - (void)initWithId:(NSUInteger)anId name:(NSString *)aName position:(NSString *)aPosition company:(NSString *)aCompany {
        if (!([super init])) {
            return nil;
        }
        id = anId;
        NSString name = [[NSString alloc] initWithString:aName];
        NSString position = [[NSString alloc] initWithString:aPosition];
        NSString company = [[NSString alloc] initWithString:aCompany];
    
        return self;
    }
    
    - (void)dealloc {
        [name release];
        [position release];
        [company release];
        [super dealloc];
    }
    
    @end
    

    And now in your calling code you can create an immutable array of speakers with:

    Speaker *speaker0 = [[Speaker alloc] initWithId:0 name:@"name0" position:@"position0" company:@"company0"];
    Speaker *speaker1 = [[Speaker alloc] initWithId:1 name:@"name1" position:@"position1" company:@"company1"];
    Speaker *speakerNull = [[Speaker alloc] initWithId:-1 name:nil position:nil company:nil];
    
    NSArray *speakerArray [[NSArray arrayWithObjects: speaker0, speaker1, speakerNull] retain]
    
    [speaker0 release];
    [speaker1 release];
    [speakerNull release];
    

    note: this is typed straight in, so feel free to mention/correct typos or errors

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

Sidebar

Related Questions

I have the following code in my model: attr_accessor :expiry_date validates_presence_of :expiry_date, :on =>
I have the following Django and Flex code: Django class Author(models.Model): name = models.CharField(max_length=30)
Lets have the following code : ( function($) { TeacherModel = Backbone.Model.extend({ defaults :
I have the following code in my model: var $name = 'Product'; var $hasMany
I have the following code - var options = new Ext.data.JsonStore({ model: 'options_model', data:
I have the following code: modelBuilder.Entity<User>().HasMany(x => x.Items).WithRequired(); The model looks like public class
Pls i have the following code in my model Letter.count(:id, :conditions => [language_id =
Okay, I have the following code: QFileSystemModel *model = new QFileSystemModel; model->setRootPath(QDir::currentPath()); model->setFilter(QDir::Files |
I have following code in my model def formatted_startdatetime unless startdatetime.nil? startdatetime.strftime('%d.%m.%Y %H:%M Uhr')
I have the following code on my model: has_attached_file :photo, :styles => { :small

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.