Re: Deadlock during NSCache flush
On Oct 23, 2013, at 10:57 PM, Maxthon Chan wrote: > Situation: I am writing a custom decoder that decodes objects from JSON-based > archives. My objects gets released prematurely, hence a manual retain is > asked for. > > I need to make this thing work across multiple platforms (that is, Cocoa > versus GNUstep) but some certain platform does not have the toll-free > bridging capabilities of CFRetain/CFRelease functions, or even lacked > CoreFoundation at all (that is, GNUstep can be configured to disable > toll-free bridging in their implementation of CoreFoundation, or the > CoreFoundation library can be missing entirely since it is optional to them). > Calls to those functions are what I have to do to make the decoder work. If you need to manipulate retain counts directly, the supported mechanisms are: 1. call CFRetain or CFRelease or CFAutorelease. 2. call -retain or -release or -autorelease from a non-ARC file. Do not call objc_retain or objc_release or objc_autorelease directly. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Deadlock during NSCache flush
Neither is appropriate in my situation: Only one touch-up is needed so converting entire file (even just one method since it is extremely long) to MRR is is inappropriate and I need portability to GNUstep so CoreFoundation (and quite portion of Foundation) have to be avoided. First part of the situation ruled out messages and second part ruled out CF* functions. OS X built Foundation on top of CoreFoundation but GNUstep built their CoreFoundation side by side with Foundation, so CoreFoundation cannot be assumed to be exist (and in most cases, it doesn't) On Oct 24, 2013, at 18:04, Greg Parker wrote: > On Oct 23, 2013, at 10:57 PM, Maxthon Chan wrote: >> Situation: I am writing a custom decoder that decodes objects from >> JSON-based archives. My objects gets released prematurely, hence a manual >> retain is asked for. >> >> I need to make this thing work across multiple platforms (that is, Cocoa >> versus GNUstep) but some certain platform does not have the toll-free >> bridging capabilities of CFRetain/CFRelease functions, or even lacked >> CoreFoundation at all (that is, GNUstep can be configured to disable >> toll-free bridging in their implementation of CoreFoundation, or the >> CoreFoundation library can be missing entirely since it is optional to >> them). Calls to those functions are what I have to do to make the decoder >> work. > > If you need to manipulate retain counts directly, the supported mechanisms > are: > 1. call CFRetain or CFRelease or CFAutorelease. > 2. call -retain or -release or -autorelease from a non-ARC file. > > Do not call objc_retain or objc_release or objc_autorelease directly. > > > -- > Greg Parker gpar...@apple.com Runtime Wrangler > > signature.asc Description: Message signed with OpenPGP using GPGMail ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Deadlock during NSCache flush
On Oct 24, 2013, at 3:10 AM, Maxthon Chan wrote: > Neither is appropriate in my situation: Only one touch-up is needed so > converting entire file (even just one method since it is extremely long) to > MRR is is inappropriate Write a helper function in a separate non-ARC file. Do not call objc_retain or objc_release or objc_autorelease directly. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Deadlock during NSCache flush
On 24/10/2013, at 12:10 PM, Maxthon Chan wrote: > Neither is appropriate in my situation Time for a small bit of conditional compilation then? --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Deadlock during NSCache flush
That does not work with GNUstep build system. With that system, I can only control ARC status on a per-target basis, and I cannot guarantee the non-existence of CoreFoundation on a GNUstep system. On Oct 24, 2013, at 18:23, Greg Parker wrote: > On Oct 24, 2013, at 3:10 AM, Maxthon Chan wrote: >> Neither is appropriate in my situation: Only one touch-up is needed so >> converting entire file (even just one method since it is extremely long) to >> MRR is is inappropriate > > Write a helper function in a separate non-ARC file. > > Do not call objc_retain or objc_release or objc_autorelease directly. > > > -- > Greg Parker gpar...@apple.com Runtime Wrangler > > signature.asc Description: Message signed with OpenPGP using GPGMail ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Deadlock during NSCache flush
Quite difficult as they emulated platform defines well, and I cannot reliably detect either GNUSTEP or __LINUX__ flags. On Oct 24, 2013, at 18:30, Graham Cox wrote: > > On 24/10/2013, at 12:10 PM, Maxthon Chan wrote: > >> Neither is appropriate in my situation > > > Time for a small bit of conditional compilation then? > > --Graham > > signature.asc Description: Message signed with OpenPGP using GPGMail ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Deadlock during NSCache flush
And by the way, why not? It is well documented in LLVM documentations that those functions are required to be identical to the corresponding methods. Are you refusing your own dogfood, Apple? On Oct 24, 2013, at 18:23, Greg Parker wrote: > On Oct 24, 2013, at 3:10 AM, Maxthon Chan wrote: >> Neither is appropriate in my situation: Only one touch-up is needed so >> converting entire file (even just one method since it is extremely long) to >> MRR is is inappropriate > > Write a helper function in a separate non-ARC file. > > Do not call objc_retain or objc_release or objc_autorelease directly. > > > -- > Greg Parker gpar...@apple.com Runtime Wrangler > > signature.asc Description: Message signed with OpenPGP using GPGMail ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Confirm 10.9 GM build number?
Me too - I finally got OS X upgraded to the release version and it's 13A603, that's what appears to be on the appstore right now. On 23 Oct, 2013, at 4:00 am, Robert Martin wrote: > 13A603 is the last GM seed I downloaded… > > > On Oct 22, 2013, at 3:21 PM, Jens Alfke wrote: > >> Can someone who’s installed the public release of Mavericks reply with the >> build number (e.g. from the About This Mac panel)? I’m running the GM seed, >> 13A598, and I’d like to make sure it’s the same as the actual release. >> Thanks. >> >> —Jens >> ___ >> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >> >> 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: >> https://lists.apple.com/mailman/options/cocoa-dev/robmartin%40frontiernet.net >> >> This email sent to robmar...@frontiernet.net > > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > https://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org > > This email sent to r...@rols.org ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Deadlock during NSCache flush
On Oct 24, 2013, at 3:39 AM, Maxthon Chan wrote: > On Oct 24, 2013, at 18:23, Greg Parker wrote: >> On Oct 24, 2013, at 3:10 AM, Maxthon Chan wrote: >>> Neither is appropriate in my situation: Only one touch-up is needed so >>> converting entire file (even just one method since it is extremely long) to >>> MRR is is inappropriate >> >> Write a helper function in a separate non-ARC file. >> >> Do not call objc_retain or objc_release or objc_autorelease directly. > > And by the way, why not? It's not published API. That should be a good enough reason. The author of those functions is telling you not to. That is also typically a good reason. The ARC optimizer will recognize your calls to these functions, assume they were generated by the ARC compiler, and possibly mis-optimize your code as a result. That is irrelevant given the first two reasons above, but may be helpful to know if you were hoping to just use them and get away with it. > It is well documented in LLVM documentations that those functions are > required to be identical to the corresponding methods. The documentation says that their effect on the retain count is semantically equivalent to a message send. That does not mean you can call them yourself. That documentation is primarily instructions for implementers. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Deadlock during NSCache flush
On Oct 24, 2013, at 3:37 AM, Maxthon Chan wrote: > Quite difficult as they emulated platform defines well, and I cannot reliably > detect either GNUSTEP or __LINUX__ flags. I can’t believe they don’t offer some kind of flag for detecting that environment. Every other platform API I can think of does. But if so, then add your own custom flag via -D in the Makefile. Basically, you can’t use portability to a non-Apple platform as an excuse for why you have to call internal APIs on an Apple platform. —Jens smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Not documented: NSArray responds to -allObjects
Starting somewhere after OS X 10.6, NSArray instances respond to the NSSet method -allObjects. I can’t find any documentation of this. Also, it is not declared in the header NSArray.h Although it does what you’d expect, returning a copy of self, this can lead to some interesting bugs, particularly when running in 10.6 after testing in a current system :( And in some cases one may want to reconsider the usual strategy of preferring -respondsToSelector: instead of -isKindOfClass: for introspection. Just to make sure that I hadn’t implemented -allObjects in a forgotten category, I ran the following test in a new little Command-Line Tool project and target… #import void Check(Class class) { BOOL doesRespond = [class instancesRespondToSelector:@selector(allObjects)] ; NSLog(@"%hhd for %@", doesRespond, NSStringFromClass(class)) ; } int main(int argc, const char * argv[]) { @autoreleasepool { Check([NSSet class]) ; Check([NSMutableSet class]) ; Check([NSArray class]) ; Check([NSMutableArray class]) ; Check([NSString class]) ; Check([NSMutableString class]) ; NSObject* a = [NSArray arrayWithObjects: @"a", @"b", @"c", nil] ; SEL selector = @selector(allObjects) ; if ([a respondsToSelector:selector]) { NSLog(@"%@ %p DOES respond to allObjects.", [a className], a) ; NSSet* s = [a performSelector:selector] ; NSLog(@"allObjects returned %@ %p: %@", [s className], s, s) ; } else { NSLog(@"%@ does NOT respond to allObjects.", [a className]) ; } } return 0 ; } *** Result, in 10.9: 2013-10-24 07:02:19.752 Junk[27092:303] 1 for NSSet 2013-10-24 07:02:19.755 Junk[27092:303] 1 for NSMutableSet 2013-10-24 07:02:19.756 Junk[27092:303] 1 for NSArray 2013-10-24 07:02:19.756 Junk[27092:303] 1 for NSMutableArray 2013-10-24 07:02:19.757 Junk[27092:303] 0 for NSString 2013-10-24 07:02:19.757 Junk[27092:303] 0 for NSMutableString 2013-10-24 07:02:19.758 Junk[27092:303] __NSArrayI 0x100400d10 DOES respond to allObjects. 2013-10-24 07:02:19.759 Junk[27092:303] allObjects returned __NSArrayI 0x100300d90: ( a, b, c ) Program ended with exit code: 0 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Not documented: NSArray responds to -allObjects
I agree, that method exists, not quite sure what your question is though. Depends what you want to do with introspection. If you want to ensure a class responds to allObjects and you expect if it does it returns an NSArray, that still works in this case, if you are trying to work out what an object is by checking what methods it supports, it's fragile and is going to get broken however hard you try and that is an unfortunate fact. If it's all your code you can limit that, if you're writing a library you are at the mercy of any category anyone added to anything anywhere. I do personally feel that somewhere around the time class clusters arrived on the scene, a method isKindOfClassReally should have arrived too which hides the implementation from the interface On 24 Oct, 2013, at 10:19 pm, Jerry Krinock wrote: > > Starting somewhere after OS X 10.6, NSArray instances respond to the NSSet > method -allObjects. I can’t find any documentation of this. Also, it is not > declared in the header NSArray.h > > Although it does what you’d expect, returning a copy of self, this can lead > to some interesting bugs, particularly when running in 10.6 after testing in > a current system :( And in some cases one may want to reconsider the usual > strategy of preferring -respondsToSelector: instead of -isKindOfClass: for > introspection. > > Just to make sure that I hadn’t implemented -allObjects in a forgotten > category, I ran the following test in a new little Command-Line Tool project > and target… > > #import > > void Check(Class class) { >BOOL doesRespond = [class > instancesRespondToSelector:@selector(allObjects)] ; >NSLog(@"%hhd for %@", doesRespond, NSStringFromClass(class)) ; > } > > int main(int argc, const char * argv[]) { > >@autoreleasepool { >Check([NSSet class]) ; >Check([NSMutableSet class]) ; >Check([NSArray class]) ; >Check([NSMutableArray class]) ; >Check([NSString class]) ; >Check([NSMutableString class]) ; > >NSObject* a = [NSArray arrayWithObjects: > @"a", @"b", @"c", nil] ; > >SEL selector = @selector(allObjects) ; >if ([a respondsToSelector:selector]) { >NSLog(@"%@ %p DOES respond to allObjects.", [a className], a) ; >NSSet* s = [a performSelector:selector] ; >NSLog(@"allObjects returned %@ %p: %@", [s className], s, s) ; >} >else { >NSLog(@"%@ does NOT respond to allObjects.", [a className]) ; >} >} > >return 0 ; > } > > *** Result, in 10.9: > > 2013-10-24 07:02:19.752 Junk[27092:303] 1 for NSSet > 2013-10-24 07:02:19.755 Junk[27092:303] 1 for NSMutableSet > 2013-10-24 07:02:19.756 Junk[27092:303] 1 for NSArray > 2013-10-24 07:02:19.756 Junk[27092:303] 1 for NSMutableArray > 2013-10-24 07:02:19.757 Junk[27092:303] 0 for NSString > 2013-10-24 07:02:19.757 Junk[27092:303] 0 for NSMutableString > 2013-10-24 07:02:19.758 Junk[27092:303] __NSArrayI 0x100400d10 DOES respond > to allObjects. > 2013-10-24 07:02:19.759 Junk[27092:303] allObjects returned __NSArrayI > 0x100300d90: ( >a, >b, >c > ) > Program ended with exit code: 0 > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > https://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org > > This email sent to r...@rols.org ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSTextField, maximum string length, bindings and NSFormatter
Have I missed something or is access to a decent NSFormatter subclass to handle NSTextField string length limiting troublesome? There is some form on this: http://stackoverflow.com/questions/827014/how-to-limit-nstextfield-text-length-and-keep-it-always-upper-case/827598#827598 http://www.cocoabuilder.com/archive/cocoa/184885-nsformatter-interfering-with-bindings-continuous-update.html However the solutions provided have issues, some with bindings, and most suggestions don't handle pasted text well. I am currently using the following. Comments, suggested improvements etc welcome. Jonathan @interface BPPlainTextFormatter : NSFormatter { NSInteger _maxLength; } /*! Set the maximum string length. Note that to use this class within a Nib: 1. Add an NSFormatter as a Custom Formatter. 2. In the Identity inspector set the Class to BPPlainTextFormatter 3. In user defined attributes add Key Path: maxlength Type: Number Value: 30 Note that rather than attaching formatter instances to individual cells they can be positioned in the nib Objects section and referenced by numerous controls. A name, such as Plain Text Formatter 100, can be used to identify the formatters max length. */ @property NSInteger maxLength; @end #define _TRACE #import "BPPlainTextFormatter.h" @implementation BPPlainTextFormatter @synthesize maxLength = _maxLength; - (id)init { if(self = [super init]){ self.maxLength = INT_MAX; } return self; } - (id)initWithCoder:(NSCoder *)aDecoder { // support Nib based initialisation self = [super initWithCoder:aDecoder]; if (self) { self.maxLength = INT_MAX; } return self; } #pragma mark - #pragma mark Textual Representation of Cell Content - (NSString *)stringForObjectValue:(id)object { NSString *stringValue = nil; if ([object isKindOfClass:[NSString class]]) { // A new NSString is perhaps not required here // but generically a new object would be generated stringValue = [NSString stringWithString:object]; } return stringValue; } #pragma mark - #pragma mark Object Equivalent to Textual Representation - (BOOL)getObjectValue:(id *)object forString:(NSString *)string errorDescription:(NSString **)error { BOOL valid = YES; // Be sure to generate a new object here or binding woe ensues // when continuously updating bindings are enabled. *object = [NSString stringWithString:string]; return valid; } #pragma mark - #pragma mark Dynamic Cell Editing - (BOOL)isPartialStringValid:(NSString **)partialStringPtr proposedSelectedRange:(NSRangePointer)proposedSelRangePtr originalString:(NSString *)origString originalSelectedRange:(NSRange)origSelRange errorDescription:(NSString **)error { BOOL valid = YES; NSString *proposedString = *partialStringPtr; if ([proposedString length] > self.maxLength) { // The original string has been modified by one or more characters (via pasting). // Either way compute how much of the proposed string can be accommodated. NSInteger origLength = origString.length; NSInteger insertLength = self.maxLength - origLength; // If a range is selected then characters in that range will be removed // so adjust the insert length accordingly insertLength += origSelRange.length; // Get the string components NSString *prefix = [origString substringToIndex:origSelRange.location]; NSString *suffix = [origString substringFromIndex:origSelRange.location + origSelRange.length]; NSString *insert = [proposedString substringWithRange:NSMakeRange(origSelRange.location, insertLength)]; #ifdef _TRACE NSLog(@"Original string: %@", origString); NSLog(@"Original selection location: %u length %u", origSelRange.location, origSelRange.length); NSLog(@"Proposed string: %@", proposedString); NSLog(@"Proposed selection location: %u length %u", proposedSelRangePtr->location, proposedSelRangePtr->length); NSLog(@"Prefix: %@", prefix); NSLog(@"Suffix: %@", suffix); NSLog(@"Insert: %@", insert); #endif // Assemble the final string *partialStringPtr = [NSString stringWithFormat:@"%@%@%@", prefix, insert, suffix]; // Fix-up the proposed selection range proposedSelRangePtr->location = origSelRange.location + insertLength; proposedSelRangePtr->length = 0; #ifdef _TRACE NSLog(@"Final string: %@", *partialStringPtr); NSLog(@"Final selection location: %u length %u", proposedSelRangePtr->location, proposedSelRangePtr->length); #endif valid = NO; } return valid; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not pos
Re: How to create source-list programmatically?
On Oct 18, 2013, at 3:48 PM, Hoon Hwangbo wrote: > So should I always use the IB to make source-list correctly? Is there no > *purely programatic* - with only code - way to do that? You can set up source lists in code. Search the docs for "selectionHighlightStyle" and "sourcelist", especially the older AppKit release notes from when source list support was initially added. In particular, you want to do: [outlineView setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleSourceList]; Cheers, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextField, maximum string length, bindings and NSFormatter
For limiting text in NSTextField this works well: (_limit == 5, 30, etc.) - (BOOL)isPartialStringValid:(NSString *__autoreleasing *)partialStringPtr proposedSelectedRange:(NSRangePointer)proposedSelRangePtr originalString:(NSString *)origString originalSelectedRange:(NSRange)origSelRange errorDescription:(NSString *__autoreleasing *)error { NSString *partialStr = *partialStringPtr; if ([partialStr length]) { if ([partialStr length] <= _limit) { *partialStringPtr = [partialStr uppercaseString]; return NO; } *partialStringPtr = [NSString stringWithString:origString]; *proposedSelRangePtr = NSMakeRange(origSelRange.location, origSelRange.length); return NO; } else { return YES; } } Want only certain char? Do that: - (NSCharacterSet *)forbiddenSet { if (!_forbiddenSet) { NSString *alphaStr = @"qwertyuiopasdfghjklzxcvbnm"; NSMutableCharacterSet *allowedSet = [NSMutableCharacterSet characterSetWithCharactersInString:alphaStr]; [allowedSet addCharactersInString:[alphaStr uppercaseString]]; _forbiddenSet = [allowedSet invertedSet]; } return _forbiddenSet; } - (BOOL)isPartialStringValid:(NSString *__autoreleasing *)partialStringPtr proposedSelectedRange:(NSRangePointer)proposedSelRangePtr originalString:(NSString *)origString originalSelectedRange:(NSRange)origSelRange errorDescription:(NSString *__autoreleasing *)error { NSString *partialStr = *partialStringPtr; if ([partialStr length]) { NSRange rangeOfForbiddenChar = [partialStr rangeOfCharacterFromSet:[self forbiddenSet]]; if ((rangeOfForbiddenChar.location == NSNotFound) && ([partialStr length] <= _limit)) { *partialStringPtr = [partialStr uppercaseString]; return NO; } *partialStringPtr = [NSString stringWithString:origString]; *proposedSelRangePtr = NSMakeRange(origSelRange.location, origSelRange.length); return NO; } else { return YES; } } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextField, maximum string length, bindings and NSFormatter
Dmitriy On 24 Oct 2013, at 16:41, Dmitriy Balakirev wrote: > For limiting text in NSTextField this works well: (_limit == 5, 30, etc.) > > - (BOOL)isPartialStringValid:(NSString *__autoreleasing *)partialStringPtr > proposedSelectedRange:(NSRangePointer)proposedSelRangePtr > originalString:(NSString *)origString > originalSelectedRange:(NSRange)origSelRange >errorDescription:(NSString *__autoreleasing *)error { > >NSString *partialStr = *partialStringPtr; >if ([partialStr length]) { >if ([partialStr length] <= _limit) { >*partialStringPtr = [partialStr uppercaseString]; >return NO; >} >*partialStringPtr = [NSString stringWithString:origString]; >*proposedSelRangePtr = NSMakeRange(origSelRange.location, > origSelRange.length); >return NO; >} else { >return YES; >} > } > This sort of illustrates my point. IMHO this does not work well (certainly not when compared to a WPF TextBox). I think: 1. Pasting is not handled adequately (sufficient text should be pasted in up to the maxLength). 2. If a range of characters is selected then the selected characters should be removed and then sufficient text should be pasted in up to the maxLength. Jonathan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Not documented: NSArray responds to -allObjects
On Oct 24, 2013, at 10:19 AM, Jerry Krinock wrote: > Starting somewhere after OS X 10.6, NSArray instances respond to the NSSet > method -allObjects. I can’t find any documentation of this. Also, it is not > declared in the header NSArray.h I see it's also documented for NSEnumerator, NSHashTable, and NSPointerArray. Might be worth filing a Radar requesting that method be made official published API like it is for the other collection classes. There might be times when you want to be able to send allObjects to a collection without knowing what kind of collection it is, and it seems silly to have to special-case NSArray. If Apple treats it the same as firstObject, you should only have to wait, what, ten years to get the API publicly exposed? :) --Andy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Not documented: NSArray responds to -allObjects
On Thu, 24 Oct 2013 07:19:51 -0700, Jerry Krinock said: >Just to make sure that I hadn’t implemented -allObjects in a forgotten >category, I ran the following test in a new little Command-Line Tool >project and target… You could also set OBJC_PRINT_REPLACED_METHODS=YES in the environment. That's how I originally discovered my firstObject NSArray category method was in conflict. Cheers, -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Not documented: NSArray responds to -allObjects
On Oct 24, 2013, at 10:35 AM, Sean McBride wrote: > You could also set OBJC_PRINT_REPLACED_METHODS=YES in the environment. > That's how I originally discovered my firstObject NSArray category method was > in conflict. This is why I always put a namespace prefix on any category methods I add to system classes. (I believe that’s an official recommendation from Apple, too.) —Jens ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Field editors behavior.
Can someone explain what the reason behind this NSTextView (i. e. every field editor) behavior: If we type something in text field('test', for example) and then select all, copy, and finally past several times, we get 'testtesttest'. But if we instead do double click on text (selecting word 'test'), copy and then past, we will get 'test test test'. What reason adding spaces here? And if we want past 'test' inside "test" we will get "te test st" but not "tetestst". Weird... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Field editors behavior.
Figured out this is smart copy/paste working. Not really smart for me… 25 окт. 2013 г., в 0:17, Dmitriy Balakirev написал(а): > Can someone explain what the reason behind this NSTextView (i. e. every field > editor) behavior: > If we type something in text field('test', for example) and then select all, > copy, and finally past several times, we get 'testtesttest'. > But if we instead do double click on text (selecting word 'test'), copy and > then past, we will get 'test test test'. What reason adding spaces here? > And if we want past 'test' inside "test" we will get "te test st" but not > "tetestst". Weird... > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Field editors behavior.
On Oct 24, 2013, at 2:17 PM, Dmitriy Balakirev wrote: > Can someone explain what the reason behind this NSTextView (i. e. every field > editor) behavior: > If we type something in text field('test', for example) and then select all, > copy, and finally past several times, we get 'testtesttest'. > But if we instead do double click on text (selecting word 'test'), copy and > then past, we will get 'test test test'. What reason adding spaces here? > And if we want past 'test' inside "test" we will get "te test st" but not > "tetestst". Weird... I think that's a function of "samrt insert and delete"--look up the smartInsertDeleteEnabled method of NSTextView. HTH, Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business" ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Not documented: NSArray responds to -allObjects
On Oct 24, 2013, at 9:19 AM, Jerry Krinock wrote: > Starting somewhere after OS X 10.6, NSArray instances respond to the NSSet > method -allObjects. I can’t find any documentation of this. Also, it is not > declared in the header NSArray.h > > Although it does what you’d expect, returning a copy of self, this can lead > to some interesting bugs, particularly when running in 10.6 after testing in > a current system :( And in some cases one may want to reconsider the usual > strategy of preferring -respondsToSelector: instead of -isKindOfClass: for > introspection. That is precisely why I dislike the -respondsToSelector: approach. You never know if you might accidentally call some undocumented method that you were unaware some class had. Either -isKindOfClass: or making a protocol containing -allObjects and making NSSet and other methods conform to it via categories seems safer in general. On Oct 24, 2013, at 9:56 AM, Roland King wrote: > Depends what you want to do with introspection. If you want to ensure a class > responds to allObjects and you expect if it does it returns an NSArray, that > still works in this case It may work, but you're still calling private methods... :-/ Charles ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Spotlight importer don't work anymore under Mavericks (sandbox error)
Hi, I have a spotlight importer for a sandboxed coredata application, derived directly from the Xcode 4.x template and working embedded in the app. The importer works under OS X 10.7 and 10.8 but fails in allocating the NSManagedModel from the storeURL located in the sandbox at containerdir/Data/Library/CoreData/LocalConfig/.support/model.mom In console I see a related sandbox error at the same time of my error: 24/10/13 19:31:49,364 sandboxd[351]: ([2437]) mdworker(2437) deny file-read-xattr /Users/gt/Library/Containers/it.iltofa.Janus/Data/Library/CoreData/LocalConfig/.support/model.mom (import fstype:hfs fsflag:480D000 flags:24005F diag:0 isXCode:0 uti:it.iltofa.janus plugin:/Janus Notes.app/Contents/Library/Spotlight/Janus NotesImporter.mdimporter - find suspect file using: sudo mdutil -t 22334033) The store is allocated in the “main” app with: NSURL *cacheDirectory = [[NSFileManager defaultManager] URLForDirectory:NSLibraryDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:&localError]; cacheDirectory = [cacheDirectory URLByAppendingPathComponent:@"CoreData/LocalConfig/" isDirectory:YES]; if(![[NSFileManager defaultManager] createDirectoryAtURL:cacheDirectory withIntermediateDirectories:YES attributes:nil error:&localError]) { ALog(@"Error creating %@: %@", cacheDirectory, [localError description]); assert(NO); } NSString *externalRecordsSupportFolder = [cacheDirectory path]; NSDictionary *options = @{NSMigratePersistentStoresAutomaticallyOption: @YES, NSInferMappingModelAutomaticallyOption: @YES, NSExternalRecordExtensionOption: @"janus", NSExternalRecordsDirectoryOption: externalRecordsSupportFolder, NSExternalRecordsFileFormatOption: NSXMLExternalRecordType }; _localStore = [_psc addPersistentStoreWithType:NSSQLiteStoreType configuration:@“LocalConfig” URL:storeURL options:options error:&localError]; The failing call on the importer is: _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:self.modelURL]; where self.modelURL is inited as: NSDictionary *pathInfo = [NSPersistentStoreCoordinator elementsDerivedFromExternalRecordURL:[NSURL fileURLWithPath:filePath]]; self.modelURL = [NSURL fileURLWithPath:[pathInfo valueForKey:NSModelPathKey]]; IIRC this is the template code. I suspected a signing error, but the importer built with XCode 4 was not signed at all, and it is signed on Xcode 5 with the same identity as the main app. The importer embedded in the app freshly downloaded from the App Store works as intended under ML with no error at all and fails under Mavericks with the error above. I was not able to find anything on the Internet and I’m out of ideas… It seems strange to me that this is a bug because I think this is a very common case (at least, I think that a core data app with a spotlight importer is not *so* strange) any hint/suggestion will be appreciated… more code is available on request, in case it will be useful. Thank you in advance, gt ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextField, maximum string length, bindings and NSFormatter
On Oct 24, 2013, at 9:01 AM, jonat...@mugginsoft.com wrote: > Have I missed something or is access to a decent NSFormatter subclass to > handle NSTextField string length limiting troublesome? > > There is some form on this: > http://stackoverflow.com/questions/827014/how-to-limit-nstextfield-text-length-and-keep-it-always-upper-case/827598#827598 > http://www.cocoabuilder.com/archive/cocoa/184885-nsformatter-interfering-with-bindings-continuous-update.html > > However the solutions provided have issues, some with bindings, and most > suggestions don't handle pasted text well. > > I am currently using the following. Comments, suggested improvements etc > welcome. I recall that this can be tricky. Below is a method that I dug up from an old NSFormatter subclass that handles both min/max lengths, non-stored delimiters and filtering to acceptable characters, which I recall is also paste-proof. I can send the whole class files if you care. - (BOOL)isPartialStringValid:(NSString **)partial proposedSelectedRange:(NSRange *)proposedRange originalString:(NSString *)original originalSelectedRange:(NSRange)originalRange errorDescription:(NSString **)errorDescription { // ignore empty if( ! [*partial length] ) return YES; // we want a mutable string NSMutableString *newString = [NSMutableString stringWithString:*partial]; // if single deletion, adjust to ignore delimiters by changing what is expected to be deleted if( proposedRange->location == originalRange.location && originalRange.length == 1 && originalRange.location > 0 ) { while( ! [allowedCharacters characterIsMember:[original characterAtIndex:proposedRange->location]] ) { proposedRange->location--; } // re-adjust string & change orig [newString deleteCharactersInRange:NSMakeRange( proposedRange->location, originalRange.location - proposedRange->location )]; originalRange.location = proposedRange->location; } NSUInteger proposedLocation = proposedRange->location; // strip down--this will include removing delimiters & updating location [newString setString:[self filterToAllowed:newString location:&proposedLocation]]; // are we too long? if( maxLength > 0 && [newString length] > maxLength ) { // delete from added NSUInteger delta = [newString length] - maxLength; proposedLocation -= delta; [newString deleteCharactersInRange:NSMakeRange( proposedLocation, delta )]; NSBeep(); } // determine the string being added: if deletion or filter actions make orig before proposed, consider empty added NSString *addedString = nil; if( originalRange.location < proposedLocation ) addedString = [newString substringWithRange:NSMakeRange( originalRange.location, proposedLocation-originalRange.location )]; if( [addedString length] ) { addedString = [self caseFoldString:addedString precursor:[newString substringToIndex:originalRange.location]]; [newString replaceCharactersInRange:NSMakeRange( originalRange.location, proposedLocation-originalRange.location ) withString:addedString]; } else if( originalRange.location < [newString length] ) { // if no added--i.e. deletion or all added was filtered out--only check case folding if not at end addedString = [self caseFoldString:[newString substringWithRange:NSMakeRange( originalRange.location, 1 )] precursor:[newString substringToIndex:originalRange.location]]; [newString replaceCharactersInRange:NSMakeRange( originalRange.location, 1 ) withString:addedString]; } // now format & check changed NSString *finalString = [self formatString:newString location:&proposedLocation]; BOOL valid = [*partial isEqualToString:finalString]; // update proposed location proposedRange->location = proposedLocation; // check completions if( completions ) { NSUInteger i, count = [completions count]; for( i=0; i= [finalString length] ) { *proposedRange = NSMakeRange( [finalString length], [proposed length] - [finalString length] ); finalString = proposed; break; } } } // always set *partial = finalString; return valid; } HTH, Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business" ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
operatingSystemVersionString replacement
The documentation tells me that NSProcessInfo operatingSystemVersionString "is human readable, localized, and is appropriate for displaying to the user. This string is not appropriate for parsing." Ok. So what do I use for parsing? like: if ( current_os_x_version < 10.9 ) then do something... Once there was Gestalt, but this is deprecated since 10.8. Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: operatingSystemVersionString replacement
You can use uname(3) (on sone other system it is listed as uname(2)) - that is the most classic UNIX way of telling a system from another. On Oct 25, 2013, at 11:49, Gerriet M. Denkmann wrote: > The documentation tells me that NSProcessInfo operatingSystemVersionString > "is human readable, localized, and is appropriate for displaying to the user. > This string is not appropriate for parsing." > > Ok. So what do I use for parsing? > > like: if ( current_os_x_version < 10.9 ) then do something... > > Once there was Gestalt, but this is deprecated since 10.8. > > Gerriet. > > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > https://lists.apple.com/mailman/options/cocoa-dev/xcvista%40me.com > > This email sent to xcvi...@me.com signature.asc Description: Message signed with OpenPGP using GPGMail ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: operatingSystemVersionString replacement
On 25 Oct 2013, at 10:53, Maxthon Chan wrote: > You can use uname(3) (on sone other system it is listed as uname(2)) - that > is the most classic UNIX way of telling a system from another. This returns: sysname = "Darwin" machine = "x86_64" release = "13.0.0" version = "Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64" Maybe there is something which gives me "10.9" or "10.8.5" or anything more Mac-like? > > On Oct 25, 2013, at 11:49, Gerriet M. Denkmann wrote: > >> The documentation tells me that NSProcessInfo operatingSystemVersionString >> "is human readable, localized, and is appropriate for displaying to the >> user. This string is not appropriate for parsing." >> >> Ok. So what do I use for parsing? >> >> like: if ( current_os_x_version < 10.9 ) then do something... >> >> Once there was Gestalt, but this is deprecated since 10.8. >> ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: operatingSystemVersionString replacement
On Oct 24, 2013, at 8:49 PM, Gerriet M. Denkmann wrote: > The documentation tells me that NSProcessInfo operatingSystemVersionString > "is human readable, localized, and is appropriate for displaying to the user. > This string is not appropriate for parsing." > > Ok. So what do I use for parsing? > > like: if ( current_os_x_version < 10.9 ) then do something... > > Once there was Gestalt, but this is deprecated since 10.8. What are you trying to do? What sort of thing is inside "do something" ? -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: operatingSystemVersionString replacement
Darwin is the name of OS X kernel so that is plain okay. The release 13.0.0 means NeXTSTEP 13.0.0 (Do you remember that what was NeXTSTEP later became OS X?) which means OS X 10.9.0. The equation is that NeXTSTEP a.b.c = OS X 10.(a-4).b (OS X 10.0 = NeXTSTEP 4, the last version of NeXTSTEP that is publicly available was 3.3) On Oct 25, 2013, at 12:21, Gerriet M. Denkmann wrote: > > On 25 Oct 2013, at 10:53, Maxthon Chan wrote: > >> You can use uname(3) (on sone other system it is listed as uname(2)) - that >> is the most classic UNIX way of telling a system from another. > > This returns: > sysname = "Darwin" > machine = "x86_64" > release = "13.0.0" > version = "Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; > root:xnu-2422.1.72~6/RELEASE_X86_64" > > Maybe there is something which gives me "10.9" or "10.8.5" or anything more > Mac-like? > > >> >> On Oct 25, 2013, at 11:49, Gerriet M. Denkmann wrote: >> >>> The documentation tells me that NSProcessInfo operatingSystemVersionString >>> "is human readable, localized, and is appropriate for displaying to the >>> user. This string is not appropriate for parsing." >>> >>> Ok. So what do I use for parsing? >>> >>> like: if ( current_os_x_version < 10.9 ) then do something... >>> >>> Once there was Gestalt, but this is deprecated since 10.8. >>> > signature.asc Description: Message signed with OpenPGP using GPGMail ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: operatingSystemVersionString replacement
On 25 Oct 2013, at 11:24, Greg Parker wrote: > On Oct 24, 2013, at 8:49 PM, Gerriet M. Denkmann wrote: >> The documentation tells me that NSProcessInfo operatingSystemVersionString >> "is human readable, localized, and is appropriate for displaying to the >> user. This string is not appropriate for parsing." >> >> Ok. So what do I use for parsing? >> >> like: if ( current_os_x_version < 10.9 ) then do something... >> >> Once there was Gestalt, but this is deprecated since 10.8. > > What are you trying to do? What sort of thing is inside "do something" ? Working around bugs which have been fixed in 10.9. (E.g. 15005906). Kind regards, Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: operatingSystemVersionString replacement
On Oct 24, 2013, at 9:46 PM, Gerriet M. Denkmann wrote: > On 25 Oct 2013, at 11:24, Greg Parker wrote: >> On Oct 24, 2013, at 8:49 PM, Gerriet M. Denkmann >> wrote: >>> The documentation tells me that NSProcessInfo operatingSystemVersionString >>> "is human readable, localized, and is appropriate for displaying to the >>> user. This string is not appropriate for parsing." >>> >>> Ok. So what do I use for parsing? >>> >>> like: if ( current_os_x_version < 10.9 ) then do something... >>> >>> Once there was Gestalt, but this is deprecated since 10.8. >> >> What are you trying to do? What sort of thing is inside "do something" ? > > Working around bugs which have been fixed in 10.9. (E.g. 15005906). The typical recommendation for cases like this is to check NSFoundationVersionNumber or NSAppKitVersionNumber. See "Runtime Version Check" in the AppKit release note for examples. https://developer.apple.com/library/mac/releasenotes/AppKit/RN-AppKit/ -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: operatingSystemVersionString replacement
Well I prefer uname() as it is 1) POSIX standard, cross-platform method and 2) more fine grained as it tells minor versions apart. (e.g. I can tell Mavericks DP4 apart from Mavericks DP7 from Mavericks GM from App Store release of Mavericks from Mavericks 10.9.1) On Oct 25, 2013, at 13:29, Greg Parker wrote: > On Oct 24, 2013, at 9:46 PM, Gerriet M. Denkmann wrote: >> On 25 Oct 2013, at 11:24, Greg Parker wrote: >>> On Oct 24, 2013, at 8:49 PM, Gerriet M. Denkmann >>> wrote: The documentation tells me that NSProcessInfo operatingSystemVersionString "is human readable, localized, and is appropriate for displaying to the user. This string is not appropriate for parsing." Ok. So what do I use for parsing? like: if ( current_os_x_version < 10.9 ) then do something... Once there was Gestalt, but this is deprecated since 10.8. >>> >>> What are you trying to do? What sort of thing is inside "do something" ? >> >> Working around bugs which have been fixed in 10.9. (E.g. 15005906). > > The typical recommendation for cases like this is to check > NSFoundationVersionNumber or NSAppKitVersionNumber. > > See "Runtime Version Check" in the AppKit release note for examples. > https://developer.apple.com/library/mac/releasenotes/AppKit/RN-AppKit/ > > > -- > Greg Parker gpar...@apple.com Runtime Wrangler > > > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > https://lists.apple.com/mailman/options/cocoa-dev/xcvista%40me.com > > This email sent to xcvi...@me.com signature.asc Description: Message signed with OpenPGP using GPGMail ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: operatingSystemVersionString replacement
> On Oct 24, 2013, at 10:36 PM, Maxthon Chan wrote: > > Well I prefer uname() as it is 1) POSIX standard, cross-platform method and > 2) more fine grained as it tells minor versions apart. (e.g. I can tell > Mavericks DP4 apart from Mavericks DP7 from Mavericks GM from App Store > release of Mavericks from Mavericks 10.9.1) Except that there’s no guarantee that AppKit had changed between different uname version changes, nor vice versa. If the bug you're working around is in AppKit, use NSAppKitVersionNumber, until such time that a new OS release makes it a built-on-or-after check which you can base on the target SDK (or eliminate entirely). That is the _only_ correct approach. Any other suggestion is incorrect. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: operatingSystemVersionString replacement
On Oct 24, 2013, at 10:36 PM, Maxthon Chan wrote: > Well I prefer uname() as it is 1) POSIX standard, cross-platform method If you're already working around an OS bug then it should be acceptable to use OS-specific means to do so. > 2) more fine grained as it tells minor versions apart. (e.g. I can tell > Mavericks DP4 apart from Mavericks DP7 from Mavericks GM from App Store > release of Mavericks from Mavericks 10.9.1) If you look at the documentation of NSFoundationVersionNumber and NSAppKitVersionNumber you'll see that they change in almost every release. uname() gives you a kernel version number, which similarly changes in almost every release but is not guaranteed to do so. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com