• 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 questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie questions


  • Subject: Re: Newbie questions
  • From: Xavier Elizalde <email@hidden>
  • Date: Wed, 26 Apr 2006 02:39:04 +1000

I got it figured out for #1- the book doesn't explain that you need a further path past the ".app" package. Appending "/Contents/MacOS/Foo" fixed the problem. As for #2, I actually misunderstood the task and found I was doing it already. After spending heaps of time working on it and finally reading the task again, of course. I thought it meant to write information in the application bundle, not just read from the application bundle and write in ~/Library/Preferences. Thanks for the help.

Xavier


On 25/04/2006, at 11:10 PM, Ondra Cada wrote:

1. It says on page 294 in Chapter 15 that you can override preference settings with "Application -[Key name] [Value name]" from the Terminal. But whenever I try to do that, it gives me an error, saying there is no directory with the same name as the [Key name] in my home directory. Is there a newer way to do this that works properly?


How do you try that exactly?

It works like this: to launch manually e.g., TextEdit with pref Foo set to Bar (which of course would do nothing, for TextEdit ignores pref "Foo"), you have to enter this in Terminal:

/Applications/TextEdit.app/Content/MacOS/TextEdit -Foo Bar

If you -- as can be assumed -- instead want to do this directly from Xcode, use the executable Get Info, and in the arguments pane just add something like "-Foo Bar".


2. On page 296, the third exercise at the end of Chapter 15 says to modify the example application "so that it reads its application defaults from a .plist file contained as a resource in its application bundle" rather than in ~/Library/Preferences. I can't figure out how to do that.


Haven't read the book, but if I follow properly what it meant by that, the appropriate code should look kind of like this (written in Mail, typos etc. probable :), no error checking (you should take e.g., case there is no plist gracefully)):


NSString *plistPath=[[NSBundle mainBundle] pathForResource:@"YourPlistName" ofType:@"YourPlistSuffix"];
NSDictionary *plistContent=[NSDictionary dictionaryWithContentsOfFile:plistPath];
[[NSUserDefaults standardUserDefaults] registerDefaults:plistContents];
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc

_______________________________________________ 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
  • Follow-Ups:
    • Re: Newbie questions
      • From: Ondra Cada <email@hidden>
References: 
 >Newbie questions (From: Xavier Elizalde <email@hidden>)
 >Re: Newbie questions (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: Temporary object created at runtime with Core Data
  • Next by Date: Re: Cocoa and other languages, was: .Mac support to C/C++ application
  • Previous by thread: Re: Newbie questions
  • Next by thread: Re: Newbie questions
  • Index(es):
    • Date
    • Thread