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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:54:03+00:00 2026-05-25T01:54:03+00:00

This is the default code that comes part of a page base app .

  • 0

This is the default code that comes part of a page base app .
_pageData basically takes a number in and returns a month .
I would like to do something quite simple but is giving me grief in Objective C . I would basically like to declare an immutable Array with strings and instead of _pageData converting a number into a month, I would like use this same number as an index in the array and return the matching string .

I hope it makes sense .

EDIT (more code)

@interface ModelController()
@property (readonly, strong, nonatomic) NSArray *pageData;
@end

@implementation ModelController

@synthesize pageData = _pageData;

- (id)init
{
    self = [super init];
    if (self) {
        // Create the data model.
//        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//        _pageData = [[dateFormatter monthSymbols] copy];

        NSArray *items = [NSArray arrayWithObjects:@"one", @"two", @"three", nil];
        NSString *item = [items objectAtIndex:1];
        _pageData = item;


    return self;
}

- (DataViewController *)viewControllerAtIndex:(NSUInteger)index storyboard:(UIStoryboard *)storyboard
{   
    // Return the data view controller for the given index.
    if (([self.pageData count] == 0) || (index >= [self.pageData count])) {
        return nil;
    }

    // Create a new view controller and pass suitable data.
    DataViewController *dataViewController = [storyboard instantiateViewControllerWithIdentifier:@"DataViewController"];

    dataViewController.dataObject = [self.pageData objectAtIndex:index];
    return dataViewController;
}
  • 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-25T01:54:04+00:00Added an answer on May 25, 2026 at 1:54 am

    hopefully this snippet helps. You can create an array from static strings and then index into to read one of them.

    NSArray *items = [NSArray arrayWithObjects:@"one", @"two", @"three", nil];
    NSString *item = [items objectAtIndex:1];
    NSLog(@"item=%@", item);
    

    concerning your month example, if it’s months be careful about getting it out of a array of static strings. For an example that’s fine but for a real app that may get localized, it’s better to get it from date objects.

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

Sidebar

Related Questions

This code extract is from database.sql file that comes with KohanaJobs app. CREATE TABLE
Does the java compiler (the default javac that comes in JDK1.6.0_21) optimize code to
Assuming MyClass uses the default destructor (or no destructor), and this code: MyClass *buffer
this is my link in my page asp:HyperLink ID=HyperLink1 runat=server NavigateUrl=~/Default.aspx>Add Record /asp:HyperLink with
Given this class public partial class Default : Page { private IRepository repo; ...
I have some code that creates a table like this: for($i=0; $i<$fields_num; $i++) {
Error: A Web Part or Web Form Control on this Page cannot be displayed
the directory structure I'm trying to achieve would be this: application/default/views/layouts/layout.phtml application/default/views/scripts/index/index.phtml application/admin/views/layouts/layout.phtml application/admin/views/scripts/index/index.phtml
I tried to follow this but the default modelbinder let my array null on
I have a weird problem, and I don't know if this is the default

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.