• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: (Newbie) Have Tips on Loading Remote Dictionary?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (Newbie) Have Tips on Loading Remote Dictionary?


  • Subject: Re: (Newbie) Have Tips on Loading Remote Dictionary?
  • From: Ryan Britton <email@hidden>
  • Date: Fri, 10 Mar 2006 17:13:15 -0800

You have to notify the observers that you're updating the values. Basically, you call [self willChangeValueForKey:@"someKey"], perform the actual changes, then call [self didChangeValueForKey:@"someKey"]. You can call any number of these you want as long as they're in matched pairs. So, in your example, you could call all the willChangeValueForKey:, load your dictionary, then call all the didChangeValueForKey:

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ ObjC_classic/Protocols/NSKeyValueObserving.html

For interface items, make sure you run these on the main thread or you'll get weird results though.


On Mar 10, 2006, at 5:03 PM, Peter Sampson wrote:

Hello,

I'm running some tests and trying to figure out how to load data from a plist from a remote location (without NSCoder or Archiving). I've been using code samples found around the web (specifically Scott Stevenson's sites) to try and get it working -- some of you will no doubt recognize it.

I want to load a PLIST from a URL and then get the values into ivars for KVC/Bindings.

The code below will load the data and parse it into a dictionary. But, it doesn't appear to set the values and update the interface.

All getter/setter methods are working and setup, and "continually updates values" is also checked for bindings on the interface.

@implementation MainObject

- (void) awakeFromNib
{
    [NSApp setDelegate: self];
    [self loadDataFromDisk];
}

- (void) loadDataFromDisk
{

NSDictionary * inputValues;
MainObject    * person = [[MainObject alloc] init];

NSURL * myURL;
myURL = [NSURL URLWithString: @"http://www.kobry.com/eg.plist";];

NSDictionary * contents;
contents = [NSDictionary dictionaryWithContentsOfURL: myURL];
NSLog(@"%@", contents);
[person setValuesForKeysWithDictionary: inputValues];

}

Thanks for your help!

Cheers,

Peter Sampson
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >(Newbie) Have Tips on Loading Remote Dictionary? (From: Peter Sampson <email@hidden>)

  • Prev by Date: (Newbie) Have Tips on Loading Remote Dictionary?
  • Next by Date: Re: movie trailers from apple.com
  • Previous by thread: (Newbie) Have Tips on Loading Remote Dictionary?
  • Next by thread: Spotlight Metadata attribute keys
  • Index(es):
    • Date
    • Thread