• 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: Archiving strategy - comments please
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Archiving strategy - comments please


  • Subject: Re: Archiving strategy - comments please
  • From: Daniel Jalkut <email@hidden>
  • Date: Tue, 14 Jun 2005 08:25:22 -0700

Hi Andy,

On Jun 14, 2005, at 5:31 AM, Andy Bettis wrote:

(I know decodeLongForKey isn't there any more - should I use int? int32_t? I still have an instictive fear of int from back when you weren't sure of the size, and I need 32 bits for these.)


How about decodeInt32ForKey? 

As an aside, what is a good system for storing the key names in the interface file? In my old (C++) system I kept an enum of single character identifiers but it would be nice to have meaningful labels. Can I set up static NSStrings?


Yes, global or file-scope NSString works well here.  You get a single point of definition and any possible performance overhead of creating the NSStrings dynamically during each pass at runtime is eliminated.

I like to define the static NSString in the source file that "owns" the information:

NSString* kMyKeyedName = @"kMyKeyedName";

And then, if this string needs to be available to any other file, just define an extern reference in the owner's header or in a global header file (e.g. for widely shared notification or preference keys):

extern NSString* kMyKeyedName;

I end up doing this so much that I wrote an Xcode script to take the string declaration and create an extern declaration for it. I put this in my Xcode scripts menu and assigned a keyboard shortcut:

#! /usr/bin/perl -w
#
# -- PB User Script Info --
# %%%{PBXName=Create NSString Extern Decls}%%%
# %%%{PBXInput=Selection}%%%
# %%%{PBXOutput=Pasteboard}%%%
# %%%{PBXKeyEquivalent=@8}%%%
#
my $outputString = "";

my @selection = <STDIN>;       # read the selection from standard input

if (!@selection) { return; };  # no chars in selection, nothing to do


foreach my $line (@selection) {
        # get everything up to the "="
        my @halves = split(/ =/, $line);
        my $thisDecl = "extern " . $halves[0] . ";\n";
        $outputString .= $thisDecl;
}


#print "%%%{PBXSelection}%%%";
print $outputString;
#print "%%%{PBXSelection}%%%";

 _______________________________________________
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: 
 >Archiving strategy - comments please (From: Andy Bettis <email@hidden>)

  • Prev by Date: Re: Getting a reference to an NSMenuItem from another nib?
  • Next by Date: Re: User-defined global hotkeys
  • Previous by thread: Archiving strategy - comments please
  • Next by thread: Multiple movable modals
  • Index(es):
    • Date
    • Thread