3

I have an iOS app that requires me to have a "bank" of multiple strings. What I mean is that I need to have several strings that I can call upon at any time. Here is what I am thinking of.

// Strings.h
#define STR_ONE @"1"
#define STR_TWO @"2"
// ...

And when I need to use these strings, I simply include the header file. I chose to go with a header file because there will be many of these strings, and I just wanted to keep them separate. So the question: Is this the best approach to solve my problem? Are there any alternate (and better) ways that I am missing?

Side notes: Is there any memory management I need to be thinking about here? Should this be written to a file, and drawn upon from there?

Thankyou

Brian Tracy
  • 6,801
  • 2
  • 33
  • 48

1 Answers1

-2

NSArray: you can store a fixed amount of string insiden an array

NSArray* nameArr = [NSArray arrayWithObjects: @"Jill Valentine", @"Peter Griffin", @"Meg Griffin"

NSMutableArray: this type of array can expand and decrease in size.

NSMutableArray *names = [[NSMutableArray alloc] init];

[self.names addObject:@"Harry Potter"];

If the amount of Strings is not enorm, a simple Plist will work for you. But i also would recommend you to read about core data.

Property List Link

Community
  • 1
  • 1
simonkaspers1
  • 616
  • 4
  • 16