• 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: load a Resource file template and search/replace a file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: load a Resource file template and search/replace a file


  • Subject: Re: load a Resource file template and search/replace a file
  • From: Nathan Kinsinger <email@hidden>
  • Date: Mon, 19 May 2008 10:47:24 -0600


On May 19, 2008, at 8:31 AM, Jens Alfke wrote:


On 19 May '08, at 4:49 AM, Kyle Sluder wrote:

- load the template from resource file

Read the documentation on NSBundle.

Specifically, the -pathToResource... family of methods will give you absolute paths to files in your Resources directory. (NSBundle doesn't load the files for you, though.)


- search and replace the file to produce another file.

Read the documentation on NSXMLParser.

NSXMLDocument would work better. Initialize one given the path to the file, then use XPath expressions on the root NSXMLElement to find the locations to replace, then change the contents of those elements. Finally, get the string of the entire document and write that to a file (using -[NSString writeToFile:].)

NSString could be used as well, try
newFileString = [stringFromFile stringByReplacingOccurrencesOfString:@"INPUT_PATH" withString:newInputPathString]


Another option would be to put %@ in the two places you want to input strings and use
newFileString = [NSString stringWithFormat:stringFromFile, newInputPathString, newOutputDirString]
just make sure to put the new strings in the same order as the %@s exist in the file string.


--Nathan
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: load a Resource file template and search/replace a file
      • From: "Wayne Shao" <email@hidden>
References: 
 >load a Resource file template and search/replace a file (From: "Wayne Shao" <email@hidden>)
 >Re: load a Resource file template and search/replace a file (From: "Kyle Sluder" <email@hidden>)
 >Re: load a Resource file template and search/replace a file (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: Cocoa et al as HCI usability problem
  • Next by Date: Re: load a Resource file template and search/replace a file
  • Previous by thread: Re: load a Resource file template and search/replace a file
  • Next by thread: Re: load a Resource file template and search/replace a file
  • Index(es):
    • Date
    • Thread