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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:39:34+00:00 2026-05-21T07:39:34+00:00

I am using this code below my imports to define some info. I would

  • 0

I am using this code below my imports to define some info. I would like to instead use a plist to pull this info. How can I switch it over?

static NSUInteger kCGRectY = 520;
static NSUInteger kCGRectH = 340;
static NSString *kImage = @"Cover.png";
static NSString *kMImage = @"IMG_0172.JPG";
static NSString *kNames = @"WHO ELSE WORKED ON IT";
static NSString *kTitle = @"PROJECT DANDELION";
static NSString *kText  = @"Lorem ipsum dolor sit amet, consectetur adipisicing elit";

In the code I use it like:

[pageView setImage:[UIImage imageNamed:kImage]];
UIImage *image = [UIImage imageNamed:kMImage];
CGSize size = [image size];
[colorView setFrame:CGRectMake(0, kCGRectY, size.width, kCGRectH)];

Any ideas?

  • 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-21T07:39:34+00:00Added an answer on May 21, 2026 at 7:39 am

    An easy way would be to use the preprocessor to handle changing all of the code which accesses it, and have an object or class handle loading the information from the plist.

    Replace the variable declarations with this code like this for each variable:

    #define kImage ([(AppDelegateClass*)[[UIApplication sharedApplication] delegate] getStringForKey:@"kImage"])
    

    Then, in your application delegate, implement the getStringForKey: method.

    - (NSString *)getStringForKey:(NSString *)key {
        static NSDictionary *plist = nil;
        if(!plist) plist = [[NSDictionary alloc] initWithContentsOfFile:@"path/to/plist.plist"];
        return [plist objectForKey:key];
    }
    

    Note that this code only handles strings, not numbers. If you want your numbers to also come from the plist, you could add them as strings and get the integer value:

    #define kCGRectY ([[(AppDelegateClass*)[[UIApplication sharedApplication] delegate] getStringForKey:@"kCGRectY"] intValue])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am using this code below to dynamically capture the name of the button
Hi I'm using this code below to let a user draw their signature on
I'm using this code, and I get the stack trace that is listed below.
I am using the below code to disable the hotkeys like Alt + f4,
I use the code below and get this error InvalidDataExcption: The magic number in
I am trying to use this code to define the APIs that are needed
Using this code to zip a folder and it works perfect on small files
Im using this code for mysql connection $con = mysql_connect(localhost:/var/lib/mysql/mysql.sock, abc , xyz); if
While using this code to serialize an object: public object Clone() { var serializer
When using this code (simplified for asking): var rows1 = (from t1 in db.TABLE1

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.