Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Global NSMutableArray

Pretty simple, what's the best way of creating and accessing a 'global' NSMutableArray?!

Its driving me mad! :p

thanks, Nick
Post edited by Gatzy118 on

Replies

  • ZunePodZunePod Posts: 1,031Registered Users
    Declaring it in the .h file.

    Hi again btw.
    Will code for food
  • Gatzy118Gatzy118 Posts: 4New Users
    ZunePod;172581 said:
    Declaring it in the .h file.

    Hi again btw.
    Im not sure you understand. I need to declare an NSMutableArray and then be able to access (run instance methods) a single instance of it from anywhere in the application.

    How?!
  • csheldrickcsheldrick Posts: 144Registered Users
    Just like he said, declare the NSMutableArray in your header file
    Check out my website and forum!

    The best way to learn is to do.

    My Apps:

    <a href="http://itunes.apple.com/us/app/ipi
  • BatmanBatman Posts: 421Registered Users
    csheldrick;172955 said:
    Just like he said, declare the NSMutableArray in your header file
    if you mean in multiple view controllers, make a singleton and declare it there
    Fast Flash Cards

    Available on the App Store

    Fast Flash Cards</f
  • GetOffTheCourtGetOffTheCourt Posts: 57Registered Users
    Batman;173129 said:
    if you mean in multiple view controllers, make a singleton and declare it there
    I would use subclasses


    //say your .h and .m file is named \"View\"

    //in the .h file declare all your variables and methods

    //this code goes under . h file

    @interface View: ViewController{

    NSMutableArray *Array

    }

    @end


    @interface View (subclass1...)

    //methods are only allowed under the subclasses no variables

    @end


    @interface View (subclass2...)

    //methods are only allowed under the subclasses no variables

    @end





    //this code goes under a new .m file
    //not the .m file of \"View\"

    @implementation View (subclass1)

    //each subclass gets it own .m file
    //and you can use every and any variable in any subclass globally from the \"View\" .h file

    @end


    @implementation View (subclass2)

    //each subclass gets it own .m file
    //and you can use every and any variable in any subclass globally from the \"View\" .h file

    @end




    I Hope This Helps & Happy Coding,
    GetOffTheCourt
  • RLScottRLScott Posts: 1,585Tutorial Authors, Registered Users
    The way to declare a global is to declare it outside of any @interface...@end block, and to define in outside of any @implementation...@end block, as in:



    //this code goes under some .h file (it doesn't matter which one)
    extern NSMutableArray *globalArray;

    @interface (of some class - it doesn't matter which one)
    ...
    @end

    Then define globalArray as in:

    NSMutableArray *globalArray;
    @implementation (any, it doesn't matter which one)
    ...
    @end


    And then, somewhere where you are sure it will only be executed once:

    globalArray = (some alloc-type of NSMutable Array creation method, retaining)

    Now you have a singleton NSMutableArray you can access from anywhere. Just don't ever release it. It's memory will be reclaimed automatically when your app closes.

    Robert Scott
    Ypsilanti, Michigan
  • dcjonesdcjones Posts: 163Registered Users
    Hi Robert,

    I have been reading your reply to this post and would like to use it in my App.

    What I am trying to do is read the content of a record held in an SQLite table and use the result in a number of views. The SQLite result is currently written into an array. At the moment I display the result in a UIScrollView and it works fine but the amount of scrolling is becoming far to long.

    I thought I would split the result between separate views. Reading your reply within the post I thought I would try and use a global array.

    The code which creates my current array is:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic -- create and push a new view controller


    NSString *name = [[objectsForCharacters objectForKey:[arrayOfCharacters objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row];


    if(self.countryView == nil) {
    CountryDetailViewController *viewController = [[CountryDetailViewController alloc] initWithNibName:@\"CountryDetailViewController\" bundle:nil];
    self.countryView = viewController;
    [viewController release];
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    }

    countries = [[NSMutableArray alloc]init];

    sqlite3 *db = [iTravelv113AppDelegate getNewDBConnection];

    NSMutableString *query;

    query = [NSMutableString stringWithFormat:@\"select * from countryList where countryName = '%@'\", name];
    const char *sql = [query UTF8String];
    sqlite3_stmt *compiledStatement = nil;

    if(sqlite3_prepare_v2(db, sql, -1, &compiledStatement, NULL) == SQLITE_OK) {
    // Loop through the results and add them to the feeds array
    while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
    // Read the data from the result row
    NSString *aName = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)] autorelease];
    NSString *aCountry = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)] autorelease];
    NSString *aCapital = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)] autorelease];
    NSString *aLanguageF = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 3)] autorelease];
    NSString *aLanguageS = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 4)] autorelease];
    NSString *aVoltage = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 5)] autorelease];
    NSString *aFreq = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 6)] autorelease];
    NSString *aDialCode = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 7)] autorelease];
    NSString *aCurrencyCode = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 8)] autorelease];
    NSString *aCurrencyName = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 9)] autorelease];
    NSString *aCurrencySymbol = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 8)] autorelease];
    NSString *aPhonePolice = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 11)] autorelease];
    NSString *aPhoneMedical = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 12)] autorelease];
    NSString *aPhoneFire = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 13)] autorelease];
    NSString *aCountryFlag = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 15)] autorelease];
    NSString *aCountryKey = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 14)] autorelease];
    NSString *aCountryOutlet = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 16)] autorelease];
    NSString *atimeZone1 = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 17)] autorelease];
    NSString *atimeZone2 = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 18)] autorelease];
    NSString *atimeZone3 = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 19)] autorelease];


    // Create a new country object with the data from the database
    Country *country = [[Country alloc] initWithName:aName countryName:aCountry capitalCity:aCapital
    firstLang:aLanguageF secondLang:aLanguageS voltage:aVoltage freq:aFreq dialCode:aDialCode
    currencyCode:aCurrencyCode currencyName:aCurrencyName currencySymbol:aCurrencySymbol
    phonePolice:aPhonePolice phoneMedical:aPhoneMedical phoneFire:aPhoneFire countryFlag:aCountryFlag
    countryKey:aCountryKey countryOutletType:aCountryOutlet
    timeZone1:atimeZone1 timeZone2:atimeZone2 timeZone3:atimeZone3];

    // Add the country object to the countries Array
    [countries addObject:country];

    [country autorelease];


    // Setup the animation
    [self.navigationController pushViewController:self.countryView animated:YES];
    // Set the title of the view to the countries name
    self.countryView.title = [country countryName];

    [self.countryView.countryName setText:[country countryName]];
    [self.countryView.capitalCity setText:[country capitalCity]];
    [self.countryView.firstLang setText:[country firstLang]];
    [self.countryView.secondLang setText:[country secondLang]];
    [self.countryView.currencyCode setText:[country currencyCode]];
    [self.countryView.currencyName setText:[country currencyName]];
    [self.countryView.voltage setText:[country voltage]];
    [self.countryView.freq setText:[country freq]];
    [self.countryView.phonePolice setText:[country phonePolice]];
    [self.countryView.phoneMedical setText:[country phoneMedical]];
    [self.countryView.phoneFire setText:[country phoneFire]];
    [self.countryView.dialCode setText:[country dialCode]];
    [self.countryView.countryOutletType setText:[country countryOutletType]];
    [self.countryView.timeZone1 setText:[country timeZone1]];
    [self.countryView.timeZone2 setText:[country timeZone2]];
    [self.countryView.timeZone3 setText:[country timeZone3]];

    [self.countryView setCountry:[country countryName]];



    UIImage *currencySymbol = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[country currencySymbol] ofType:@\"png\"]];
    self.countryView.currencySymbol.image = currencySymbol;
    [currencySymbol autorelease];

    UIImage *countryFlag = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[country countryFlag] ofType:@\"gif\"]];
    self.countryView.countryFlag.image = countryFlag;
    [countryFlag autorelease];

    }

    }
    // Release the compiled statement from memory
    sqlite3_finalize(compiledStatement);



    }


    In the .h I have made a change from "NSMutableArray *countries" which was inside of the @interface...@end block to "extern NSMutableArray *countries;" which is now outside of the @interface...@end bloc. I have also declared "extern NSMutableArray *countries;" before the @implementation section in the .m file.

    The part I am not clear about is:

    globalArray = (some alloc-type of NSMutable Array creation method, retaining)


    Can you advise me how to implement my array in to this statement so I can use it in other views.

    Many thanks for any advice and help you can provide.
    Many thanks, keep safe and well.







    Dereck
  • RLScottRLScott Posts: 1,585Tutorial Authors, Registered Users
    By changing the .h file
    from "NSMutableArray *countries" which was inside of the @interface...@end block to "extern NSMutableArray *countries;" which is now outside of the @interface...@end block
    you are saying that countries, which used to be an instance variable of the class, is now a global variable. So countries is what you want to use instead of globalArray.

    Next, you should not use "extern" in the .m file. "extern" is only for the declaration in the .h file, not for the actual variable definition in the .m file.

    Finally, you already created countries and it is retained (because you used alloc and did not release it).

    So if you take away that one unnecessary extern, then you would have the setup you need to make countries a global NSMutableArray. To access it in other views, only need to import the .h file that declares countries into the .m file of those views.

    I should warn you that using a global variable like this invites problems if you are careless. Remember that countries is not actually the NSMutableArray itself. It is just a pointer to that NSMutableArray. Like all Objective-C objects, this object can only be accessed through pointers. And the memory that it points to needs to be dynamically managed. Normally this dynamic memory management is taken care of for you when you make a property of an object.

    By looking at your code, I see that you set countries in response to a didSelectRowAtIndexPath. Therefore you might set countries more than once. When you do that, the old NSMutableArray that countries used to point to becomes leaked memory, unless you first release it. This would have been handled automatically for you if you were content to use properties and the standard retaining setter that comes with it. But by implementing a global variable, you have abandoned the use of properties. So you have to do the work that the properties would have done for you automatically. If you really understand the retain/release system and are committed to taking the care needed to release dynamically allocated memory at just the right time, then you can make this work. But this is not normally done.

    OK, I have done my best to warn you against using a global variable as a pointer to a NSMutableArray. So the choice is up to you.
  • dcjonesdcjones Posts: 163Registered Users
    Hi Robert,

    Many thanks for such a details response. After reading tier reply I think I need to look at how I am going the get the result I need in another way.

    Because "countries" will be set more than once your right in saying it's not the way to do it. The only reason I was looking at using a global array is because I cannot think of any other way to retain the variables in each of the views.

    I need to rethink the whole process.

    Again, many thanks for your advice.
    Many thanks, keep safe and well.







    Dereck
  • RLScottRLScott Posts: 1,585Tutorial Authors, Registered Users
    How about making it a property of the app delegate? It would not be exactly global, but it would be accessible from anywhere.
  • dcjonesdcjones Posts: 163Registered Users
    Hi Robert,

    From what I have read, "and since I started trying to learn Objective C, which was back in March, I've done a lot of reading but not enough by the look of it" your suggestion is a great idea. The only problem I have is I am not sure how to implement it.

    Do you have the time to show me the syntax I should use to make the "countries" array a property of the App delegate and how I would make a call to it from a UIView.

    I think if I can get over this issue I may be home and dry.

    Again, many thanks in advance.
    Many thanks, keep safe and well.







    Dereck
  • RLScottRLScott Posts: 1,585Tutorial Authors, Registered Users
    See the end of my tutorial on globals here. Just use NSMutableArray countries instead of NSString userName. And never set the value of countries except with the setter:

    appDelegate.countries =...
  • dcjonesdcjones Posts: 163Registered Users
    Hi Robert,

    Sorry to be a complete pain in the neck with this.

    My appDelegate .h file is:

    #import <sqlite3.h> // Import the SQLite database framework
    #import <UIKit/UIKit.h>

    @interface iTravelv113AppDelegate : NSObject <UIApplicationDelegate> {

    UIWindow *window;
    UINavigationController *navigationController;

    // Database variables
    NSString *databaseName;
    NSString *databasePath;

    NSMutableArray *countries;

    NSString *airportname;



    NSMutableArray *arrayOfCharacters;
    NSMutableDictionary *objectsForCharacters;

    NSMutableArray *arrayOfAirports;

    // Array to store the country objects
    NSMutableArray *airports;
    }

    @property (nonatomic, retain) NSMutableArray *countries;
    @property (nonatomic, retain) IBOutlet UIWindow *window;
    @property (nonatomic, retain) IBOutlet UINavigationController *navigationController;


    -(void)checkAndCreateDatabase;
    +(sqlite3*)getNewDBConnection;


    The appDelegate .m file is:

    #import <sys/socket.h>
    #import <netinet/in.h>
    #import <arpa/inet.h>
    #import <netdb.h>
    #include <SystemConfiguration/SCNetworkReachability.h>

    #import \"iTravelv113AppDelegate.h\"
    #import \"RootViewController.h\"



    @implementation iTravelv113AppDelegate

    @synthesize window;
    @synthesize navigationController;
    @synthesize countries;


    and so on...

    I have a file which reads my SQL data and creates an ARRAY containing the record requested by the user. A part of the file is below:

    // Create a new country object with the data from the database
    Country *country = [[Country alloc] initWithName:aName countryName:aCountry capitalCity:aCapital
    firstLang:aLanguageF secondLang:aLanguageS voltage:aVoltage freq:aFreq dialCode:aDialCode
    currencyCode:aCurrencyCode currencyName:aCurrencyName currencySymbol:aCurrencySymbol
    phonePolice:aPhonePolice phoneMedical:aPhoneMedical phoneFire:aPhoneFire countryFlag:aCountryFlag
    countryKey:aCountryKey countryOutletType:aCountryOutlet
    timeZone1:atimeZone1 timeZone2:atimeZone2 timeZone3:atimeZone3];

    // Add the country object to the countries Array
    [countries addObject:country];
    appDelegate.countries = countries;
    [country autorelease];


    The part I am struggling with is assigning the content of the ARRAY to the "appDelegate.countries = countries". I know this is because I don't know how this is done even thou I have read and re-read your tutorial. Basically I am having a very thick head time.

    Can you help me advance this issue a little further.
    Many thanks, keep safe and well.







    Dereck
  • dcjonesdcjones Posts: 163Registered Users
    Hi Robert,

    again, sorry to be a pain in the neck.

    I have gotten a little further, I now have the following in the file which reads the country record in to the array. I have changed he name of the array from countries to countriesList to avoid a clash with another var.

    // Create a new country object with the data from the database
    Country *country = [[Country alloc] initWithName:aName countryName:aCountry capitalCity:aCapital
    firstLang:aLanguageF secondLang:aLanguageS voltage:aVoltage freq:aFreq dialCode:aDialCode
    currencyCode:aCurrencyCode currencyName:aCurrencyName currencySymbol:aCurrencySymbol
    phonePolice:aPhonePolice phoneMedical:aPhoneMedical phoneFire:aPhoneFire countryFlag:aCountryFlag
    countryKey:aCountryKey countryOutletType:aCountryOutlet
    timeZone1:atimeZone1 timeZone2:atimeZone2 timeZone3:atimeZone3];

    // Add the country object to the countries Array
    [countries addObject:country];

    iTravelv113AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    appDelegate.countriesList = countries;
    NSLog(@\"The contents of countriesList = %@\",appDelegate.countriesList);
    [country autorelease];


    The App complies without error but the output of the NSLog is:

    2010-07-31 20:47:52.163 iTravelv113[2983:207] Database Successfully Opened
    2010-07-31 20:47:52.165 iTravelv113[2983:207] The contents of countriesList = (
    ""
    )

    I am not to sure what this is telling me. Can you throw any light on the output.
    Many thanks, keep safe and well.







    Dereck
  • dcjonesdcjones Posts: 163Registered Users
    Hi Robert,

    Please forget the last post or two. I am moving forward and I think I may have solved my issue.

    I will let you know, many thanks again for your help.
    Many thanks, keep safe and well.







    Dereck
  • dcjonesdcjones Posts: 163Registered Users
    Hi Robert,

    Having followed your tutorial I now have the following code.

    I have created an NUMultableArray:

    NSMutableArray *acountryList;

    acountryList = [NSMutableArray new];
    [acountryList addObject: aCountry];
    [acountryList addObject: aCapital];
    [acountryList addObject: aLanguageF];
    [acountryList addObject: aLanguageS];
    [acountryList addObject: aVoltage];
    [acountryList addObject: aFreq];
    [acountryList addObject: aDialCode];
    [acountryList addObject: aCurrencyCode];
    [acountryList addObject: aCurrencyName];
    [acountryList addObject: aCurrencySymbol];
    [acountryList addObject: aPhonePolice];
    [acountryList addObject: aPhoneMedical];
    [acountryList addObject: aPhoneFire];
    [acountryList addObject: aCountryFlag];
    [acountryList addObject: aCountryOutlet];
    [acountryList addObject: atimeZone1];
    [acountryList addObject: atimeZone2];
    [acountryList addObject: atimeZone3];




    iTravelv113AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    //someClass.someString = appDelegate.userName; //..to fetch
    appDelegate.countries = acountryList; //..to write

    which when test for content holds the correct data.

    In my AppDeligate I have the following:
    .h file:

    @interface iTravelv113AppDelegate : NSObject <UIApplicationDelegate> {

    UIWindow *window;
    UINavigationController *navigationController;

    // Database variables
    NSString *databaseName;
    NSString *databasePath;

    NSMutableArray *countries;

    NSString *airportname;

    NSMutableArray *arrayOfCharacters;
    NSMutableDictionary *objectsForCharacters;

    NSMutableArray *arrayOfAirports;

    // Array to store the country objects
    NSMutableArray *airports;
    }

    @property (nonatomic, retain) NSMutableArray *countries;
    @property (nonatomic, retain) IBOutlet UINavigationController *navigationController;


    -(void)checkAndCreateDatabase;

    +(sqlite3*)getNewDBConnection;


    in the .m file:

    @implementation iTravelv113AppDelegate

    @synthesize navigationController;
    @synthesize countries;


    In the UIViewController where I want to use the content of the array I have:
    .h file:

    @interface LocalCurrencyViewController : UIViewController {

    NSMutableArray *countries;

    IBOutlet UIScrollView *scrollView;

    IBOutlet UITextView *acountryName;
    IBOutlet UITextView *acapitalCity;
    IBOutlet UITextView *afirstLang;
    IBOutlet UITextView *asecondLang;
    IBOutlet UITextView *acurrencyName;
    IBOutlet UITextView *acurrencyCode;
    IBOutlet UIImageView *acurrencySymbol;
    IBOutlet UITextView *avoltage;
    IBOutlet UITextView *afreq;
    IBOutlet UITextView *aphonePolice;
    IBOutlet UITextView *aphoneMedical;
    IBOutlet UITextView *aphoneFire;
    IBOutlet UITextView *adialCode;
    IBOutlet UIImageView *acountryFlag;
    IBOutlet UITextView *acountryOutletType;
    IBOutlet UITextView *atimeZone1;
    IBOutlet UITextView *atimeZone2;
    IBOutlet UITextView *atimeZone3;
    IBOutlet NSString *aCountry;


    }

    @property (nonatomic, retain) NSMutableArray *countries;

    @property (nonatomic, retain) IBOutlet UITextView *acountryName;
    @property (nonatomic, retain) IBOutlet UITextView *acapitalCity;
    @property (nonatomic, retain) IBOutlet UITextView *afirstLang;
    @property (nonatomic, retain) IBOutlet UITextView *asecondLang;
    @property (nonatomic, retain) IBOutlet UITextView *acurrencyName;
    @property (nonatomic, retain) IBOutlet UITextView *acurrencyCode;
    @property (nonatomic, retain) IBOutlet UIImageView *acurrencySymbol;
    @property (nonatomic, retain) IBOutlet UITextView *avoltage;
    @property (nonatomic, retain) IBOutlet UITextView *afreq;
    @property (nonatomic, retain) IBOutlet UITextView *aphonePolice;
    @property (nonatomic, retain) IBOutlet UITextView *aphoneMedical;
    @property (nonatomic, retain) IBOutlet UITextView *aphoneFire;
    @property (nonatomic, retain) IBOutlet UITextView *adialCode;
    @property (nonatomic, retain) IBOutlet UIImageView *acountryFlag;
    @property (nonatomic, retain) IBOutlet UITextView *acountryOutletType;
    @property (nonatomic, retain) IBOutlet UITextView *atimeZone1;
    @property (nonatomic, retain) IBOutlet UITextView *atimeZone2;
    @property (nonatomic, retain) IBOutlet UITextView *atimeZone3;
    @property (nonatomic, retain) IBOutlet NSString *aCountry;


    .m file

    - (void)viewDidLoad {
    [super viewDidLoad];

    iTravelv113AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    UITextView.acountryName = appDelegate.countries; //..to fetch
    NSLog(@\"The contents of countries = %@\",[countries description]);
    }


    but I am getting the following error:
    "Accessing unknown setAcountryName class method, Object cannot be set, either readonly property or setter cannot be found".

    Can you see anything I have missed.
    Many thanks, keep safe and well.







    Dereck
  • RLScottRLScott Posts: 1,585Tutorial Authors, Registered Users

    UITextView.acountryName = appDelegate.countries;

    acountryName is not a property of UITextView. Why is UITextView there?
  • dcjonesdcjones Posts: 163Registered Users
    Hi Robert,
    acountryName is not a property of UITextView. Why is UITextView there?
    That's a good question and to be truthful I don't know. What I was trying to do is make the "acountryName" available so I could eventually use it in a view.

    Assuming all the other code is correct, How do I call the content of the "countries" array so it can be used the the view I am working on.

    I know I'm a pain in the neck, sorry. But I am learning fast, I think.
    Many thanks, keep safe and well.







    Dereck
  • dcjonesdcjones Posts: 163Registered Users
    Hi Robert,

    SUCCESS, I have change my code to:

    iTravelv113AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    NSArray *tempCountry = appDelegate.countries; //..to fetch
    ccountryName.text = [tempCountry objectAtIndex:0];
    ccurrencyName.text = [tempCountry objectAtIndex:8];
    ccurrencyCode.text = [tempCountry objectAtIndex:9];


    Now I have the correct data displaying.

    Robert, many thank for all your help.
    Many thanks, keep safe and well.







    Dereck
Sign In or Register to comment.