Re: NSTextView backed by core data, undo problems
On Thu, Mar 11, 2010 at 11:38 PM, Martin Hewitson martin.hewit...@aei.mpg.de wrote: Thanks, Kyle. I figured the answer would be something like this. OK, then I'll need to rethink the architecture a bit. I was aiming for an Xcode-like interface with potentially multiple views to the same file content, but without using 'updates continuously' this is going to be more difficult to achieve. If anyone has any good suggestions, I'd be delighted to hear them. Start by reading the text system documentation, and then re-reading it. :) Then try to build a simple app that has two windows looking at the same text storage, so that typing in one causes immediate corresponding changes in the other. That'll get you the base of what you need. As far as integrating with Core Data, you will certainly need custom logic to translate the NSTextStorage world into the KVC-based NSManagedObject world. Perhaps you should subclass NSTextStorage for use in your model objects, and have its special knowledge inform your NSManagedObject subclass of pertinent changes so it can update its serialized version of the text as appropriate. This gets you the updates continuously behavior you want but uses the framework correctly to do it. Again, it's not trivial, but certainly not impossible. Our apps certainly do it. --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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Switching methods in private classes in Apple frameworks
Method exchange is dangerous because if the target class (NSConcreteNotification) does not override the target function (dealloc), you may exchange it's superclass dealloc method instead and may end up overriding a method in a base class. Use it with great care and avoid it in production code if possible. Le 12 mars 2010 à 03:00, Gideon King a écrit : This is really cool...so I can replace a method without being a subclass or category. So I implemented an NSObject subclass with the new method, and did the method exchange, and my new method was called instead of the old one, but I had a problem - the call to the switched out method (dealloc from the NSConcreteNotification) didn't work. I assumed that was because the old implementation of dealloc was now moved to my class, so I changed the method switching so that it ensures that the old dealloc is replaced with the implementation of mydealloc, and that I have added a method to the NSConcreteNotification which is called mydealloc, and does the things that the old dealloc did. This seems to work, so I thought I'd post it here in case anyone else needs to replace a method in a private class, and be able to call the original implementation. #import objc/runtime.h #import Cocoa/Cocoa.h @interface MyConcreteNotification : NSObject { } - (void)mydealloc; @end @implementation MyConcreteNotification + (void)load { Method originalMethod = class_getInstanceMethod(NSClassFromString(@NSConcreteNotification), @selector(dealloc)); Method replacedMethod = class_getInstanceMethod(self, @selector(mydealloc)); IMP imp1 = method_getImplementation(originalMethod); IMP imp2 = method_getImplementation(replacedMethod); // Set the implementation of dealloc to mydealloc method_setImplementation(originalMethod, imp2); // Add a mydealloc method to the NSConcreteNotification with the implementation as per the old dealloc method class_addMethod(NSClassFromString(@NSConcreteNotification), @selector(mydealloc), imp1, NULL); } - (void)mydealloc { NSLog(@My concrete notification is being deallocated); NSLog(@Name: %...@\nobject: %...@\nuser Info: %...@\n, [self name], [self object], [self userInfo]); // Call the original method, whose implementation was exchanged with our own. // Note: this ISN'T a recursive call, because this method should have been called through dealloc. NSParameterAssert(_cmd == @selector(dealloc)); [self mydealloc]; } @end Regards. Gideon On iPhone and 64-bit Mac, the linker enforces internal classes more strictly. NSConcreteNotification is private, so you can't link to it or subclass it. You can still get the class via runtime introspection like NSClassFromString(), which for debugging purposes ought to be good enough. -- 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: http://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org This email sent to devli...@shadowlab.org -- Jean-Daniel ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Problem with save as and freed managed object context
Having sorted out the problem that occurred when I closed files, I am now back to the save as issue (I was hoping that the two problems were related, but apparently not). I have reverted to using a stock standard NSManagedObjectContext I still haven't a clue where to look to debug this. Running it normally gives the following error: NovaMind5TP(3129,0x7fff70ee2be0) malloc: *** error for object 0x1149bdd30: pointer being freed was not allocated (gdb) po 0x1149bdd30 NSManagedObjectContext: 0x1149bdd30 (gdb) bt #0 0x7fff87290951 in malloc_error_break () #1 0x7fff871ba143 in free () #2 0x7fff8439471b in _internal_object_dispose () #3 0x7fff80e2d79a in -[NSObject(NSObject) dealloc] () #4 0x7fff874e4ff1 in -[NSManagedObjectContext dealloc] () #5 0x7fff874d40a3 in -[NSManagedObjectContext release] () #6 0x7fff80e0e246 in _CFAutoreleasePoolPop () #7 0x7fff8571a2f8 in -[NSAutoreleasePool drain] () #8 0x7fff87528eb9 in -[NSPersistentStoreCoordinator migratePersistentStore:toURL:options:withType:error:] () #9 0x7fff8654e7e2 in -[NSPersistentDocument writeToURL:ofType:forSaveOperation:originalContentsURL:error:] () #10 0x000100034301 in -[NMPersistentDocument writeToURL:ofType:forSaveOperation:originalContentsURL:error:] (self=0x1008c47f0, _cmd=0x7fff867f759e, absoluteURL=0x1149abb90, typeName=0x100819f50, saveOperation=1, absoluteOriginalContentsURL=0x1008056c0, error=0x7fff5fbfdea8) at /Users/gideon/Development/svn/trunk/mac/Source/NMPersistentDocument.m:403 #11 0x7fff864240b2 in -[NSDocument _writeSafelyToURL:ofType:forSaveOperation:error:] () #12 0x7fff864234b0 in -[NSDocument writeSafelyToURL:ofType:forSaveOperation:error:] () #13 0x7fff8654d8f1 in -[NSPersistentDocument writeSafelyToURL:ofType:forSaveOperation:error:] () #14 0x7fff8641e836 in -[NSDocument saveToURL:ofType:forSaveOperation:error:] () #15 0x7fff864218e4 in -[NSDocument _saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo:] () #16 0x7fff8641eb17 in -[NSDocument saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo:] () ... And instruments with zombies tells me: # CategoryEvent Type RefCt Timestamp Address Size Responsible Library Responsible Caller 0 NSManagedObjectContext Malloc 1 00:27.812 0x1204c3540 240 CoreData-[NSPersistentStoreCoordinator(_NSInternalMethods) _retainedAllMigratedObjectsInStore:toStore:] 1 NSManagedObjectContext Autorelease 00:28.009 0x1204c3540 0 CoreData -[NSPersistentStoreCoordinator(_NSInternalMethods) _retainedAllMigratedObjectsInStore:toStore:] 2 NSManagedObjectContext Zombie -1 00:28.011 0x1204c3540 0 CoreData-[NSManagedObjectContext(_NSInternalAdditions) _dispose:] Has anyone got any suggestions as to where to look for the cause of this? Thanks Gideon ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextView backed by core data, undo problems
Thanks a lot, I'll proceed as suggested. Martin On Mar 12, 2010, at 9:07 AM, Kyle Sluder wrote: On Thu, Mar 11, 2010 at 11:38 PM, Martin Hewitson martin.hewit...@aei.mpg.de wrote: Thanks, Kyle. I figured the answer would be something like this. OK, then I'll need to rethink the architecture a bit. I was aiming for an Xcode-like interface with potentially multiple views to the same file content, but without using 'updates continuously' this is going to be more difficult to achieve. If anyone has any good suggestions, I'd be delighted to hear them. Start by reading the text system documentation, and then re-reading it. :) Then try to build a simple app that has two windows looking at the same text storage, so that typing in one causes immediate corresponding changes in the other. That'll get you the base of what you need. As far as integrating with Core Data, you will certainly need custom logic to translate the NSTextStorage world into the KVC-based NSManagedObject world. Perhaps you should subclass NSTextStorage for use in your model objects, and have its special knowledge inform your NSManagedObject subclass of pertinent changes so it can update its serialized version of the text as appropriate. This gets you the updates continuously behavior you want but uses the framework correctly to do it. Again, it's not trivial, but certainly not impossible. Our apps certainly do it. --Kyle Sluder Martin Hewitson Albert-Einstein-Institut Max-Planck-Institut fuer Gravitationsphysik und Universitaet Hannover Callinstr. 38, 30167 Hannover, Germany Tel: +49-511-762-17121, Fax: +49-511-762-5861 E-Mail: martin.hewit...@aei.mpg.de WWW: http://www.aei.mpg.de/~hewitson ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Switching methods in private classes in Apple frameworks
Wow, that's really, really awesome. Do you have any more details on why you can't use ivars? Not calling super makes sense. Can you access properties? On Mar 11, 2010, at 8:58 PM, Gideon King wrote: Thanks Jerry, I should mention that I did get this caveat note from Greg Parker (Apple's runtime wrangler): ..you must be cautious about what your replacement method does. In particular, you must not use any of the class's ivars and you must not call [super something]. As long as you follow those, you can swap in a method from any class, or even a C function with a matching argument list. So as long as you are careful about what you do, yes it is entirely possible to replace methods at will. I hope nobody misuses it, but it certainly was essential in my debugging - yes, I found it! Yay! Essentially what appeared to be happening was that I had a notification queued which had an object in it which held a reference to a managed object, but by the time the notification was destroyed, the managed object had turned to a fault (but was not released because the notification was causing it to be retained), and the managed object context had been released as part of the document deallocation, so when my object tried to access the managed object, it tried to fire the fault on a freed managed object context...or something like that. Even if that's not exactly right in every detail, I now have the conceptual understanding of the problem and believe I will be able to fix it. What a relief! Regards Gideon On 12/03/2010, at 1:54 PM, Jerry Krinock wrote: On 2010 Mar 11, at 18:00, Gideon King wrote: This is really cool...so I can replace a method without being a subclass or category. I just need to chime in here, in case anyone missed it, to emphasize how *ALL-CAPS COOL* this is indeed. In the ReadMe of Apple's MethodReplacement.zip sample code, it states The trick is to define a category on the class whose method you want to replace. We have just learned that this sentence is incorrect. You do *not* need to define a category on the class whose method you want to replace. As Gideon showed in his code, the first argument of class_getInstanceMethod() need *not* be self, and therefore you can replace any method in *any* class, even a private one that's unknown to the SDK, with any other method in *any class*, even a different class. This makes Method Replacement much more powerful in debugging, and even patching bugs in Cocoa. I just sent Apple a wasn't helpful gram on that ReadMe. Thanks, Gideon. I hope you've found out who's sending that notification releasing your moc :) ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/danhd123%40mac.com This email sent to danhd...@mac.com ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Switching methods in private classes in Apple frameworks
*Why* is there no supported way to replace (or, rather, augment) methods in a class which one cannot override because one does not create instances of that class oneself? It seems to me that this is just as legitimate as putting a category method on that class , but the latter approach is often useless as one cannot call 'super' (and again, why not?) As for something like this breaking after a software update, it seems to me that this is likely only when a major new release comes out and, since there are _always_ issues with major new releases of OS X it doesn't actually worry me all that much. Paul Sanders. - Original Message - From: Bill Bumgarner b...@mac.com To: Gideon King gid...@novamind.com Cc: Cocoa Dev cocoa-dev@lists.apple.com Sent: Friday, March 12, 2010 6:36 AM Subject: Re: Switching methods in private classes in Apple frameworks Where careful about what you do includes only use this in debugging code or non-production instrumentation, sure Do *not* ship such shenanigans in production code. One software update later and suddenly the presumptions made about that internal method you are replacing/overriding/augmenting are no longer true and *boom*. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
incorrect bitmap date from NSBitmapImageRep from NSDate
// not work NSData *data = [NSData dataWithContentsOfFile: filename]; NSBitmapImageRep *image = [[NSBitmapImageRep alloc] initWithData: data]; as opposed to: // works fine NSImage *source = [[NSImage alloc] initWithContentsOfFile: filename]; NSSize size = [source size]; [source lockFocus]; NSBitmapImageRep *image = [[NSBitmapImageRep alloc] initWithFocusedViewRect: NSMakeRect(0.0, 0.0, size.width, size.height)]; [source unlockFocus]; // OpenGL commands gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, [image pixelsWide], [image pixelsHigh], GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, [image bitmapData]); why? as opposed to ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Use of KVC Array operators
Am 12.03.2010 um 04:34 schrieb Eli Bach: The operators mentioned on this page, particularly @unionOfSets. http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/KeyValueCoding/Concepts/ArrayOperators.html I have the following Core Data object's setup ClassAClassB ClassC relationA --relationB -- relation C where each of the relations is a many to one [one class A, many class B, and one class B, many class C]. Not all ClassB's will have ClassC objects attached to them I have an instance of classA, and I want an NSArrayController with all the ClassC objects for all the ClassB objects that are related to that specific instance of ClassA, preferably in a way that uses KVO instead of programmatically updating with fetches/predicates/etc. What would be the right way to bind the NSArrayController, assuming the nib owner has an instance of classA: How about Owner.instanceOfA.relationB.relationC ? If you ask an array for a key path you get a new array containing the resulting objects. You don’t need any operators. atze ie: bind content set to File Owner.instanceOfA.? Thanks, Eli ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: incorrect bitmap date from NSBitmapImageRep from NSDate
Exactly what does not work? The loading? Or the opengl command? If the latter I suspect that your file is not in the needed format. Does your image have alpha? atze Am 12.03.2010 um 13:09 schrieb Ariel Feinerman: // not work NSData *data = [NSData dataWithContentsOfFile: filename]; NSBitmapImageRep *image = [[NSBitmapImageRep alloc] initWithData: data]; as opposed to: // works fine NSImage *source = [[NSImage alloc] initWithContentsOfFile: filename]; NSSize size = [source size]; [source lockFocus]; NSBitmapImageRep *image = [[NSBitmapImageRep alloc] initWithFocusedViewRect: NSMakeRect(0.0, 0.0, size.width, size.height)]; [source unlockFocus]; // OpenGL commands gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, [image pixelsWide], [image pixelsHigh], GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, [image bitmapData]); why? as opposed to ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/atze%40freeport.de This email sent to a...@freeport.de ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Bison/Yacc with Objective-C ?
Bloomin' magic! Thanks, Filip, it worketh well. Hardy souls all. Tom W. Is it possible to see an example of how this might be used? I'd like to understand Bison/Yacc better and i think an example relevant to Cocoa / Objective-C would really help. Thanks, Steven ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Help visualizing something in IB
On Mar 11, 2010, at 7:43 PM, Quincey Morris wrote: On Mar 11, 2010, at 10:58, Brian Postow wrote: I should be able to just use the clipRect of the superview, right? Well, you have to observe something that produces notifications -- which means the bounds or frame of a view. You're likely not interested in the actual bounds or frame you're being notified about. You just want to be told when something that matters changes. Once you've received a notification, I think you'll simply want to examine the visibleRect of topView. Basically, if I understand correctly, you'll want to position the button view at the top of the visibleRect, and the image view in the rest of the visibleRect, and also handle the edge cases where there isn't enough room to show those subviews. yes, I think you're right. I think visibleRect is the right thing to look at. thanks a lot! Brian Postow Senior Software Engineer Acordex Imaging Systems ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Bison/Yacc with Objective-C ?
On Mar 12, 2010, at 9:00 AM, steven Hooley wrote: Bloomin' magic! Thanks, Filip, it worketh well. Hardy souls all. Tom W. Is it possible to see an example of how this might be used? I'd like to understand Bison/Yacc better and i think an example relevant to Cocoa / Objective-C would really help. Thanks, Steven Steve, The interpreter I am working on is a work in progress, but here is a copy of the yacc/bison file as it exists as I start work on it today. It imports (not includes) the Cocoa Foundation and the semantic actions are written in Objective-C. This file is incomplete as it is only two days old and I am in the process of writing the semantic actions for the statement and expression types now. But you can still see the statement and expression types that will be handled by reading the grammar. The language itself is nearly complete. As it stands now it has only one shift/reduce conflict, that caused by the inherent ambiguity in the if/else statement, but the yacc/bison approach to resolving these conflicts by using shift is the proper handling in this case. (All this means is that the parser will make sure that else statements bind to the closest then part.) This is a typical example of using yacc/bison. The language defined is a general purpose programming language. During parsing a semantic tree of the program is built out of Objective-C objects (including the representations of different kinds of statements and expressions, values, types, modules and so on). Building the tree is what the semantic actions (the code with the $$ and $1 things scattered among the rules) do. Once this representation is built, the tree is validated for programming errors as any normal compiler would do (for example, undeclared variables, argument/parameter mismatches, assigning a number to a set, and so on) and then the program is run by an interpreter. The interpreter is similar to, though much simpler than, the Java virtual machine, as it executes the semantic trees as if they were instructions to a virtual machine, while managing the run time stack and the currently active subtree of symbol tables. I am writing the validator and interpreter in parallel with the parser, so there is a lot of stuff not visible here. This is all part of a Cocoa-based genealogical software application, where this part allows users to run their own algorithms on records in their databases or to generate their own specialty reports without having to modify the application itself. The genealogical records (eg, info about events, persons, families, and so on) are all kept in tree structures that can be represented in the application's databases or externally as XML or other types of structured text (GEDCOM is the format often chosen for genealogical software but it suffers from a variety of limitations.) Thus my earlier and not so positive reference to XSLT, which is the official (and much harder) way to do this, though I expect that an XSLT program would not be able to affect the database holding the records it processes. Needless to say I am extremely pleased that all I had to do was make the suffix to the yacc file be .ym instead of .y to get Xcode to do all the right things. I don't know whether bison itself was modified or whether the Xcode build rules just do the proper renaming, but the fact that someone at Apple worried about it and then made it work, is just one of those little things that makes me so content, one might even say smirkily self-satisfied, to be developing for the Mac. And then the fact that someone on this list (thanks, Filip) knew this was even better, as I have yet to find any actual DOCUMENTATION that states that this would happen! Easter eggs in spring. Tom Wetmore, Chief Bottle Washer, DeadEnds Software // Interpreter.ym // // Created by Thomas Wetmore on 3/10/2010. // Last changed on 3/12/2010. // Copyright 2010 DeadEnds Software. All rights reserved. %{ #import Foundation/Foundation.h #import TWInterpreter.h #import TWInterpStatement.h #import TWInterpExpression.h #import TWInterpModule.h #import TWInterpLexer.h // For this parser every semantic type is an Objective-C object. #define YYSTYPE id extern TWInterpreterLexer* lexer; void yyerror (char* message); int yylex (); %} %token TYPE %right ASGNOP %left OROP %left ANDOP %left EQOP %left RELOP %left ADDOP %left MULOP %right UNARYOP %right NOTOP %token IDEN ICONS FCONS SCONS BCONS %token WHILE DO IF ELSE %token BREAK CONTINUE RETURN %% definitions : definition | definitions definition ; definition : declaration { [globalDeclarations addObject: $1]; } | module { [moduleTable setObject: $1 forKey: ((TWInterpModule*)$1).name];
What would cause persistentStoreForURL: to return nil?
I know that the URL is valid and it's readable. I can open the file in my application. I can read it into an NSData with dataWithContentsOfURL: The purpose of what I am doing is trying to migrate to an XML store to see if that will help me isolate the problem I am having with save as, which I posted about before. Here's what I do in my test in my persistent document: NSPersistentStoreCoordinator *psc = [[self managedObjectContext] persistentStoreCoordinator]; NSURL *oldURL = [NSURL fileURLWithPath:@/Users/gideon/Development/TestNMDocs/Untitled11.nm5]; NSURL *newURL = [NSURL fileURLWithPath:@/Users/gideon/Development/TestNMDocs/Untitled11.xml]; NSError *error; NSPersistentStore *myStore = [psc persistentStoreForURL:oldURL]; NSPersistentStore *xmlStore = [psc migratePersistentStore:myStore toURL:newURL options:nil withType:NSXMLStoreType error:error]; oldURL is verifiably present, readable and valid, but myStore is always nil. Any ideas? Thanks Gideon___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: What would cause persistentStoreForURL: to return nil?
What if you print out [psc persistentStores] ? I think you'll find the PSC is surprisingly fussy about the URLs. e.g. capitalisation seems to matter. So do trailing slashes. Oh, and also the difference between: file:///foo.bar file://localhost/foo.bar On 12 Mar 2010, at 15:48, Gideon King wrote: I know that the URL is valid and it's readable. I can open the file in my application. I can read it into an NSData with dataWithContentsOfURL: The purpose of what I am doing is trying to migrate to an XML store to see if that will help me isolate the problem I am having with save as, which I posted about before. Here's what I do in my test in my persistent document: NSPersistentStoreCoordinator *psc = [[self managedObjectContext] persistentStoreCoordinator]; NSURL *oldURL = [NSURL fileURLWithPath:@/Users/gideon/Development/TestNMDocs/Untitled11.nm5]; NSURL *newURL = [NSURL fileURLWithPath:@/Users/gideon/Development/TestNMDocs/Untitled11.xml]; NSError *error; NSPersistentStore *myStore = [psc persistentStoreForURL:oldURL]; NSPersistentStore *xmlStore = [psc migratePersistentStore:myStore toURL:newURL options:nil withType:NSXMLStoreType error:error]; oldURL is verifiably present, readable and valid, but myStore is always nil. Any ideas? Thanks Gideon___ 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: http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net This email sent to cocoa...@mikeabdullah.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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Use of KVC Array operators
On Mar 12, 2010, at 5:37 AM, Alexander Spohr wrote: Am 12.03.2010 um 04:34 schrieb Eli Bach: The operators mentioned on this page, particularly @unionOfSets. http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/KeyValueCoding/Concepts/ArrayOperators.html I have the following Core Data object's setup ClassA ClassB ClassC relationA -- relationB -- relation C where each of the relations is a many to one [one class A, many class B, and one class B, many class C]. Not all ClassB's will have ClassC objects attached to them I have an instance of classA, and I want an NSArrayController with all the ClassC objects for all the ClassB objects that are related to that specific instance of ClassA, preferably in a way that uses KVO instead of programmatically updating with fetches/predicates/etc. What would be the right way to bind the NSArrayController, assuming the nib owner has an instance of classA: How about Owner.instanceOfA.relationB.relationC ? If you ask an array for a key path you get a new array containing the resulting objects. You don’t need any operators. I'll try this, but I don't expect it to work, because there can be 0 or more relationB object's, and each of those object's can have 0 or more relationC objects, and just 'plain' dot syntax won't produce a superset of relationC objects (from my understanding of KVO and KVC). Eli ie: bind content set to File Owner.instanceOfA.? ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
performSelector doesn't work for modal window
Hi, All, Unfortunately NSButton click is called when button is pressed, but not when it is released. Therefore any timeconsumming process, executed on the button click, will keep the button pressed. To avoid it I've decided to use performSelector:withObject:afterDelay: message. This approach works OK for main window, but it doesn't work for a modal popup panel. More exactly, this message is sent only when modal window is closed and NSApplication is returned to the main messages loop. It looks like this is a fundamental Cocoa specifics, though I don't understand it. So, how to send a message to a modal window messages loop? I don't like to use multithreading here, though I will do it if I'll can't find another solution. Any ideas? Thanks. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
tracking Responder chain.
I have a plugin (Mozilla in case it matters) which creates a window (for registration information) with an NSTextField. I want to be able to cut and paste. However, when I do it nothing happens (The edit menu flashes, but nothing gets pasted, etc. From doing a little reading my theory is that since I'm in my own window within a plugin inside mozilla, my textField isn't in the responder chain, and so isn't getting the events... Typing into the textboxes and hitting return to get the default button works fine, so maybe that isn't the problem, but it's my current theory... Brian Postow Senior Software Engineer Acordex Imaging Systems ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: performSelector doesn't work for modal window
Try using: performSelector:withObject:afterDelay:inModes: passing: [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSModalPanelRunLoopMode, nil] to inModes: Paul Sanders - Original Message - From: Alexander Bokovikov openwo...@uralweb.ru To: cocoa-dev@lists.apple.com Sent: Friday, March 12, 2010 4:34 PM Subject: performSelector doesn't work for modal window ... I've decided to use performSelector:withObject:afterDelay: message. This approach works OK for main window, but it doesn't work for a modal popup panel. ... ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: What would cause persistentStoreForURL: to return nil?
Ah, I think I had a fundamental misunderstanding - I thought it would load the store, but it only returns it if it's already loaded in the coordinator. The documentation gives no clue of this - all it says is: Parameters URL An URL object that specifies the location of a persistent store. Return Value The persistent store at the location specified by URL. I think it would be very easy to assume (as I did) that it would load it from the URL provided. Anyway, I have it working now, only it shows that I still get the same over-releasing of the managed object context when I try to migrate it to an xml store, as what I get when I try to do a save as. I'm not sure exactly what that tells me though - probably that it's a problem somewhere in my managed objects. I'll go back again and have yet another look at every place I refer to the managed object context, and see if I can track it down. rant (3am style :-)If I had had any inkling of the problems and development overheads we would have with core data when I started this, I would never have used it - I hope it does pay off in the future to make development and maintenance easier, but for the moment, it's been a massive and unexpected investment./rant Thanks for your help Mike. Regards Gideon On 13/03/2010, at 2:09 AM, Mike Abdullah wrote: What if you print out [psc persistentStores] ? I think you'll find the PSC is surprisingly fussy about the URLs. e.g. capitalisation seems to matter. So do trailing slashes. Oh, and also the difference between: file:///foo.bar file://localhost/foo.bar ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
RE: IKFilterUIView - Problem with text fields
Hi all,I reply to my own question!Actually I managed to find what I was looking for. Look my first point below to understand what I was talking about. My problem didn't really come from the IKFilterUIView but more from the way I was applying the CIKernel in the CIFilter ! here is what I wrote : cikernel : kernel vec4 MyProcessingKernel(sampler src, float k) so I thought I should call it like that : CIImage * outputImage = [self apply:_MyProcessingFilterKernel , src, [inputK floatValue], kCIApplyOptionDefinition, [currIterationImage definition], kCIApplyOptionExtent, [currIterationImage extent], nil];// I thought [inputK floatValue] would be ok to call the kernel because I never found something in the documentation saying I shoudln't do that!! Finally I figured out that I should do that : CIVector * input = [[CIVector alloc] initWithX:[inputK floatValue]];CIImage * outputImage = [self apply:_MyProcessingFilterKernel , src, input, kCIApplyOptionDefinition, [currIterationImage definition], kCIApplyOptionExtent, [currIterationImage extent], nil] So the idea is to use a CIVector in which we put the value and use this CIVector as a parameter for the filter!!!And it works now!! That was tricky!! But regarding my second question I still have no idea! So any answer would be welcomed! ;) Thanks, Paul Date: Tue, 9 Mar 2010 17:52:53 +0100 From: paul morel elbomber...@hotmail.com Subject: IKFilterUIView - Problem with text fields To: cocoa-dev@lists.apple.com Message-ID: snt142-w54c14d6f68ea05311fdda1be...@phx.gbl Content-Type: text/plain; charset=iso-8859-1 Hi, -I am developping a program where I use an IKFilterUIView to manage the user interface for filters. I also created my own filter according to the core image filter tutorials in the Mac Dev Center. So far I have the user interface and when I interact with the sliders it works pretty well. But as soon as I try to type a value for the parameters in the text field and press 'return' is doesn't work and the program stops and I can't do anything else. In the console I have an error : MyProcessingFilter: MyProcessing: argument #1 (p) should be a CIVector object , whereas the argument p is clearly defined as a NSNumber and has never been defined as a CIVector! But this happens only with my own filter. When I try the same thing with filters already installed there is no problem with this text field! So the bindings are correct. So is there someone who would have an idea of what I could do or check or anything? I tested the filter with the ImageUnitAnalyzer and it passed! So I don't think it comes from the filter. -By the way, do you know how it is possible to choose how to display the values in the same text field, i.e. if my parameter is an integer value I don'twant to see '4.1212' but '4' when I move the slider. Thanks _ Hotmail: Trusted email with Microsoft’s powerful SPAM protection. https://signup.live.com/signup.aspx?id=60969___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
calling the run method in an AppleScript from a cocoa application
I need the ability to call an AppleScript from a Cocoa Application. I have done this in the past using NSAppleScript and it works great. This time I need to call the on run and pass in parameters. That I have not done. I looked at the following Tech note Technical Note TN2084: Using AppleScript Scripts in Cocoa Applicationshttp://developer.apple.com/mac/library/technotes/tn2006/tn2084.html#TNTAG5 and it talks about running a subroutine in apple script and passing in parameters. The example I have been able to get working, but if I try and call the run method it does not work. I suspect it is the event parameter that is incorrect. Here is code. It is basically the same code that was in the tech note but it is calling run as appose to sow_message. Run is a reserved word and clearly acts differently. NSAppleEventDescriptor* handler = [NSAppleEventDescriptor descriptorWithString: [@run lowercaseString]]; //here is where I'm trying to setup the subroutine to call NSAppleEventDescriptor* event = [NSAppleEventDescriptor appleEventWithEventClass:kASAppleScriptSuite eventID:kASSubroutineEvent //I suspect that this eventID is not correct. targetDescriptor:target returnID:kAutoGenerateReturnID transactionID:kAnyTransactionID]; [event setParamDescriptor:handler forKeyword:keyASSubroutineName]; //I suspect that this is not needed or is incorrect [event setParamDescriptor:parameters forKeyword:keyDirectObject]; Does someone know how I should be setting up these events. thanks for the help -dave ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Use of KVC Array operators
Am 12.03.2010 um 17:32 schrieb Eli Bach: On Mar 12, 2010, at 5:37 AM, Alexander Spohr wrote: Am 12.03.2010 um 04:34 schrieb Eli Bach: The operators mentioned on this page, particularly @unionOfSets. http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/KeyValueCoding/Concepts/ArrayOperators.html I have the following Core Data object's setup ClassA ClassB ClassC relationA -- relationB -- relation C where each of the relations is a many to one [one class A, many class B, and one class B, many class C]. Not all ClassB's will have ClassC objects attached to them I have an instance of classA, and I want an NSArrayController with all the ClassC objects for all the ClassB objects that are related to that specific instance of ClassA, preferably in a way that uses KVO instead of programmatically updating with fetches/predicates/etc. What would be the right way to bind the NSArrayController, assuming the nib owner has an instance of classA: How about Owner.instanceOfA.relationB.relationC ? If you ask an array for a key path you get a new array containing the resulting objects. You don’t need any operators. I'll try this, but I don't expect it to work, because there can be 0 or more relationB object's, and each of those object's can have 0 or more relationC objects, and just 'plain' dot syntax won't produce a superset of relationC objects If you have 0 Bs, you’ll have an empty array If you have Bs without Cs they just wont fill anything into the array. *methinks* it might be that you get some NSNull in there for the empty Cs. But no, this should not happen because the relationship itself is an NSSet, not a pointer that can be nil. From NSSet’s valueForKey: Discussion The returned set might not have the same number of members as the receiver. The returned set will not contain any elements corresponding to instances of valueForKey: returning nil (note that this is in contrast with NSArray’s implementation, which may put NSNull values in the arrays it returns). valueForKeyPath: is just a recursive or iterative call: Discussion The default implementation gets the destination object for each relationship using valueForKey: and returns the result of a valueForKey: message to the final object. atze (from my understanding of KVO and KVC). what is your understanding of KVC? ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: What would cause persistentStoreForURL: to return nil?
On 12 Mar 2010, at 16:48, Gideon King wrote: Ah, I think I had a fundamental misunderstanding - I thought it would load the store, but it only returns it if it's already loaded in the coordinator. The documentation gives no clue of this - all it says is: Parameters URL An URL object that specifies the location of a persistent store. Return Value The persistent store at the location specified by URL. I think it would be very easy to assume (as I did) that it would load it from the URL provided. I think the use of for is supposed to be your hint there. Cocoa uses it almost universally to mean that the returned object is already present and that you're doing nothing more than a lookup. -persistentStoreWithURL: would be more like you expected I think.___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Better sorting using threads?
On Mar 12, 2010, at 2:25 AM, Ken Ferry wrote: Does Cocoa have sorted containers so that an object can be inserted in sorted order? If so it seems like this would be far less expensive. Probably the best thing to do if you want this is to maintain the sort yourself by inserting new objects in the correct position. You can find the position using -[NSArray indexOfObject:inSortedRange:options:usingComparator:]. That's two lines instead of one to add an object to an array, which is not bad. That method is new in 10.6, but something similar has been in CoreFoundation for a while. CFArrayBSearchValues is usable on NSArray since CFArray is bridged. You can also look at -[NSArray sortedArrayHint]. The deal there is that you extract an opaque hint from a sorted array, change the array, and resort passing in the hint. This is optimized for the case when the array is still mostly sorted, but with some things out of place. I maintain a simple sorted array by rerunning -sortUsingFunction:context: for every insert (or set of inserts, since the vast majority of inserts into the array are groups of objects together). So far I haven't had any speed issues with it at all. But my case is pretty simple; it's a small array of around 100 objects, and the sort function is trivial (object.integerProperty comparison). -- Gwynne ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: calling the run method in an AppleScript from a cocoa application
Hey Dave, I think this may be what you want: http://homepage.mac.com/kenferry/software.html#KFAppleScript Kevin On Mar 12, 2010, at 8:56 AM, David Alter wrote: I need the ability to call an AppleScript from a Cocoa Application. I have done this in the past using NSAppleScript and it works great. This time I need to call the on run and pass in parameters. That I have not done. I looked at the following Tech note Technical Note TN2084: Using AppleScript Scripts in Cocoa Applicationshttp://developer.apple.com/mac/library/technotes/tn2006/tn2084.html#TNTAG5 and it talks about running a subroutine in apple script and passing in parameters. The example I have been able to get working, but if I try and call the run method it does not work. I suspect it is the event parameter that is incorrect. Here is code. It is basically the same code that was in the tech note but it is calling run as appose to sow_message. Run is a reserved word and clearly acts differently. NSAppleEventDescriptor* handler = [NSAppleEventDescriptor descriptorWithString: [@run lowercaseString]]; //here is where I'm trying to setup the subroutine to call NSAppleEventDescriptor* event = [NSAppleEventDescriptor appleEventWithEventClass:kASAppleScriptSuite eventID:kASSubroutineEvent //I suspect that this eventID is not correct. targetDescriptor:target returnID:kAutoGenerateReturnID transactionID:kAnyTransactionID]; [event setParamDescriptor:handler forKeyword:keyASSubroutineName]; //I suspect that this is not needed or is incorrect [event setParamDescriptor:parameters forKeyword:keyDirectObject]; Does someone know how I should be setting up these events. thanks for the help -dave ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/kainjow%40kainjow.com This email sent to kain...@kainjow.com ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: calling the run method in an AppleScript from a cocoa application
On 12 Mar 2010, at 16:56, David Alter wrote: I need the ability to call an AppleScript from a Cocoa Application. I have done this in the past using NSAppleScript and it works great. This time I need to call the on run and pass in parameters. That I have not done. I looked at the following Tech note Technical Note TN2084: Using AppleScript Scripts in Cocoa Applicationshttp://developer.apple.com/mac/library/technotes/tn2006/tn2084.html#TNTAG5 and it talks about running a subroutine in apple script and passing in parameters. The example I have been able to get working, but if I try and call the run method it does not work. I suspect it is the event parameter that is incorrect. Here is code. It is basically the same code that was in the tech note but it is calling run as appose to sow_message. Run is a reserved word and clearly acts differently. NSAppleEventDescriptor* handler = [NSAppleEventDescriptor descriptorWithString: [@run lowercaseString]]; //here is where I'm trying to setup the subroutine to call NSAppleEventDescriptor* event = [NSAppleEventDescriptor appleEventWithEventClass:kASAppleScriptSuite eventID:kASSubroutineEvent //I suspect that this eventID is not correct. targetDescriptor:target returnID:kAutoGenerateReturnID transactionID:kAnyTransactionID]; [event setParamDescriptor:handler forKeyword:keyASSubroutineName]; //I suspect that this is not needed or is incorrect [event setParamDescriptor:parameters forKeyword:keyDirectObject]; Try sending the open application event. Should do the trick. The run handler can take parameters if desire. theEvent = [self appleEventWithEventClass:kCoreEventClass eventID:kAEOpenApplication targetDescriptor:aTargetDescriptor returnID:kAutoGenerateReturnID transactionID:kAnyTransactionID]; Regards Jonathan Mitchell Developer http://www.mugginsoft.com ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Key-Value Observing speed
While profiling a project I'm working on, I found that while most of my time was being spent in glFlush() (which is completely expected for an OpenGL-based game), a non-trivial amount of time is being spent in dozens of KVO internal methods and functions. Most especially, I noticed that KVO (or possibly the KVC beneath it) makes heavy use of NSInvocation-based forwarding, which is known to be the slowest possible code path for message dispatch. KVO is central to my code's structure; I rely on it for everything to know what everything else is doing without sprinkling manual notifications all over the code. Is there any way to trick the runtime into taking some faster code paths? It's really troublesome to see property setter methods taking up almost as much total time as the audio converter thread in Instruments. Would it help if my properties were sets of integers instead of structures (specifically, NSPoint and NSRect are used quite a bit)? Would it be just blindly insane to think that a NSRectObject would be faster somehow than a plain NSRect because of the structure return trickery the runtime has to do? And if there's nothing I can do with Apple's KVO, is it even remotely realistic to consider writing my own quickie version of KVO that takes faster paths since I can tweak it for my uses? (Side note, Michael Ash's MAKVONotificationCenter has been a panacea for all manner of minor issues I've had with the KVO implementation, kudos Mike!) Please, no one say I shouldn't be writing a game with Objective-C; KVO is the only thing that's tripped me up speed-wise about it. (Well, that and the audio threads doing a heck of a lot of sound processing, I keep wondering if I can put my WAV files into some format that requires less CA conversion or whether it's NSSound forcing that on me...) -- Gwynne ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: incorrect bitmap date from NSBitmapImageRep from NSDate
2010/3/12 Alexander Spohr a...@freeport.de Exactly what does not work? The loading? Or the opengl command? texture is corrupted with artifact on the screen and sometimes gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, [image pixelsWide], [image pixelsHigh], GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, [image bitmapData]); take an exception If the latter I suspect that your file is not in the needed format. Does your image have alpha? format is bmp there is of the matter is that messages -initWithCIImage and -initWithFocusedViewRect read bitmap date from offscreen window so image is rendered twice, isn`t it? reference The image in the *ciImage* parameter must be fully rendered before the receiver can be initialized. If you specify an object whose rendering was deferred (and thus does not have any pixels available now), this method forces the image to be rendered immediately. Rendering the image could result in a performance penalty if the image has a complex rendering chain or accelerated rendering hardware is not available. Is the way to get NSBitmapImageRep for OpenGL without offscreen rendering image? atze Am 12.03.2010 um 13:09 schrieb Ariel Feinerman: // not work NSData *data = [NSData dataWithContentsOfFile: filename]; NSBitmapImageRep *image = [[NSBitmapImageRep alloc] initWithData: data]; as opposed to: // works fine NSImage *source = [[NSImage alloc] initWithContentsOfFile: filename]; NSSize size = [source size]; [source lockFocus]; NSBitmapImageRep *image = [[NSBitmapImageRep alloc] initWithFocusedViewRect: NSMakeRect(0.0, 0.0, size.width, size.height)]; [source unlockFocus]; // OpenGL commands gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, [image pixelsWide], [image pixelsHigh], GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, [image bitmapData]); why? as opposed to ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/atze%40freeport.de This email sent to a...@freeport.de -- best regards Ariel ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Forcing text layout
Hello, I have a page layout view, roughly based on the one in TextEdit although not quite the same. When text gets loaded into the page layout view, I need to force layout so that at least the first few pages get added (or removed if I'm replacing text that was already in there) properly. So far, I have been using the following code to force layout of the text - and this is again based on code from the TextEdit sources - which has mostly worked fine: - (void)forceInitialLayout { NSUInteger len, loc = MIN(5,[[self textStorage] length]); if ((len = [[self textStorage] length]) 0) { NSRange glyphRange; if (loc = len) loc = len - 1; // Find out which glyph index the desired character index corresponds to glyphRange = [[selflayoutManager] glyphRangeForCharacterRange:NSMakeRange(loc, 1) actualCharacterRange:NULL]; if (glyphRange.location 0) { // Now cause layout by asking a question which has to determine where the glyph is (void)[[selflayoutManager] textContainerForGlyphAtIndex:glyphRange.location- 1effectiveRange:NULL]; } } } (Note that 50,000 is just an arbitrary number of characters to get the initial layout going before the user sees the view, so that the user doesn't see pages suddenly appearing or disappearing.) As I say, this generally works fine, but I have just found a special case. If there are two pages of text, and the second page only has an image on it, and if this image was forced across to the second text container because there wasn't enough space in the first, the above method will not force layout of the second container, only the first. The result is that there should be two pages but only one appears on screen until the user scrolls,when it suddenly pops in. If I type some text after the image and try again, it works fine, but if there is just an image that has been forced onto the second page, it doesn't work. Now, as I understand it, all the above code from TextEdit does is ask a question of the layout manager that will force layout up to the given character (in the above method, up to the character at index 50,000 or up to the end of the text, whichever comes first). My guess is that asking for -textContainerForGlyphAtIndex: doesn't necessarily take into account the fact that an image might get pushed across to another page if it is too big, and may return the container it was initially intended for instead (even though the docs say that the method will return the text container in which it is laid out). So I figured I'd try asking the layout manager some different questions which, according to the docs, should cause layout. -locationForGlyphAtIndex: seems to do the job: - (void)forceInitialLayout { NSInteger charIndex = (5 [[self textStorage] length] ? [[self textStorage] length] : 5); if (charIndex 0) { charIndex -= 1; [layoutManagerlocationForGlyphAtIndex:charIndex]; } } The above code correctly lays out both pages whereas the original didn't. So my question is, is using -locationForGlyphAtIndex: just as valid a way of doing it, or is there a good reason Apple used -textContainerForGlyphAtIndex: instead? Or is there a better way to force the initial layout of text that will spill across multiple text containers? Many thanks and all the best, Keith ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
.ini file class?
It should be easy to write an Objective-C class that reads and writes .ini files, but I'd prefer to use existing art if any exists. Googling Cocoa ini file class and Objective-C ini file class turned up nothing. Any leads? — F ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Problem with save as and freed managed object context
Further information: I have just gone through every place in our code where it makes reference to the managed object context (there's only 90 of them thank goodness), and there is nothing there where we either retain or release a managed object context, or use one in a notification or anything like that. I have also found out that the managed object context that is over-released is not the one that I have in my persistent document, so all I can assume is that it is one that is created behind the scenes programmatically during the persistent store migration. I also checked our will/didTurnIntoFault and awakeFromInsert/Fetch to make sure they were clean. Found a few minor problems, but it made no difference. I did find that awakeFromFetch was called during the process of migration, but didn't find out anything else of interest. I also checked for description methods that may have caused faults to fire at the wrong time. I only found one description on one of our managed object classes, and an interesting thing happened when I commented that out - I could not save at all (trying to send an objectID message to an NSNumber). I have not tracked that one down yet. I still feel as though I'm flying blind, so any suggestions from here would be welcome (I have also logged a DTS request on this but have not had any reply from them). Time for some sleep (almost 5am), but if there are any suggestions as to where to look I'll pick them up when I wake up, and try them out. Regards Gideon On 12/03/2010, at 6:50 PM, Gideon King wrote: Having sorted out the problem that occurred when I closed files, I am now back to the save as issue (I was hoping that the two problems were related, but apparently not). I have reverted to using a stock standard NSManagedObjectContext I still haven't a clue where to look to debug this. Running it normally gives the following error: NovaMind5TP(3129,0x7fff70ee2be0) malloc: *** error for object 0x1149bdd30: pointer being freed was not allocated (gdb) po 0x1149bdd30 NSManagedObjectContext: 0x1149bdd30 (gdb) bt #0 0x7fff87290951 in malloc_error_break () #1 0x7fff871ba143 in free () #2 0x7fff8439471b in _internal_object_dispose () #3 0x7fff80e2d79a in -[NSObject(NSObject) dealloc] () #4 0x7fff874e4ff1 in -[NSManagedObjectContext dealloc] () #5 0x7fff874d40a3 in -[NSManagedObjectContext release] () #6 0x7fff80e0e246 in _CFAutoreleasePoolPop () #7 0x7fff8571a2f8 in -[NSAutoreleasePool drain] () #8 0x7fff87528eb9 in -[NSPersistentStoreCoordinator migratePersistentStore:toURL:options:withType:error:] () #9 0x7fff8654e7e2 in -[NSPersistentDocument writeToURL:ofType:forSaveOperation:originalContentsURL:error:] () ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: .ini file class?
You could write a Cocoa wrapper around an existing C/C++ library. For example http://ndevilla.free.fr/iniparser/ On Mar 12, 2010, at 10:34 AM, Fritz Anderson wrote: It should be easy to write an Objective-C class that reads and writes .ini files, but I'd prefer to use existing art if any exists. Googling Cocoa ini file class and Objective-C ini file class turned up nothing. Any leads? — F ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/kainjow%40kainjow.com This email sent to kain...@kainjow.com ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Use of KVC Array operators
On Mar 12, 2010, at 9:58 AM, Alexander Spohr wrote: I'll try this, but I don't expect it to work, because there can be 0 or more relationB object's, and each of those object's can have 0 or more relationC objects, and just 'plain' dot syntax won't produce a superset of relationC objects If you have 0 Bs, you’ll have an empty array If you have Bs without Cs they just wont fill anything into the array. *methinks* it might be that you get some NSNull in there for the empty Cs. But no, this should not happen because the relationship itself is an NSSet, not a pointer that can be nil. From NSSet’s valueForKey: Discussion The returned set might not have the same number of members as the receiver. The returned set will not contain any elements corresponding to instances of valueForKey: returning nil (note that this is in contrast with NSArray’s implementation, which may put NSNull values in the arrays it returns). valueForKeyPath: is just a recursive or iterative call: Discussion The default implementation gets the destination object for each relationship using valueForKey: and returns the result of a valueForKey: message to the final object. atze (from my understanding of KVO and KVC). what is your understanding of KVC? That it wouldn't do this merging of set's automatically. And I did just try it, and got a binding error: Cocoa Bindings: Error setting value for bound property instanceOfA of object controllerclass: 0x100675780: [_NSFaultingMutableSet 0x1006eab90 addObserver:forKeyPath:options:context:] is not supported. Key path: relationC I figured it would be something like this, which is why I was looking at the @unionOfSets operator in particular (as that's exactly what this is, a union of all sets of relationC objects from a set of relationB objects. Eli ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Better sorting using threads?
All, My concern is that keeping traditional C-arrays in sorted order means 1) finding the location for insert ( O(n) ) 2) copying a range of contiguous memory to make the location available 3) copying in new value I've made the assumption that NSArray wraps an old school contiguous C-style array ( ala C++ std:::vector ) With many sorted container insertion inserting in sorted order means 1) finding the location for inserter ( O(nlogn) ) or the like 2) create node with new value 3) swizzle some pointers to include new values .. ( ala C++ std::set ) I have a hard time seeing how this is more expensive for very large container than sorting an array when needed. The initial poster was indicating he has a container with thousands of members. Please educate me where my post illustrates ignorance. Cheers, --aj From: Gwynne Raskind gwy...@darkrainfall.org To: Ken Ferry kenfe...@gmail.com Cc: Cocoa-Dev List cocoa-dev@lists.apple.com Sent: Fri, March 12, 2010 9:14:35 AM Subject: Re: Better sorting using threads? On Mar 12, 2010, at 2:25 AM, Ken Ferry wrote: Does Cocoa have sorted containers so that an object can be inserted in sorted order? If so it seems like this would be far less expensive. Probably the best thing to do if you want this is to maintain the sort yourself by inserting new objects in the correct position. You can find the position using -[NSArray indexOfObject:inSortedRange:options:usingComparator:]. That's two lines instead of one to add an object to an array, which is not bad. That method is new in 10.6, but something similar has been in CoreFoundation for a while. CFArrayBSearchValues is usable on NSArray since CFArray is bridged. You can also look at -[NSArray sortedArrayHint]. The deal there is that you extract an opaque hint from a sorted array, change the array, and resort passing in the hint. This is optimized for the case when the array is still mostly sorted, but with some things out of place. I maintain a simple sorted array by rerunning -sortUsingFunction:context: for every insert (or set of inserts, since the vast majority of inserts into the array are groups of objects together). So far I haven't had any speed issues with it at all. But my case is pretty simple; it's a small array of around 100 objects, and the sort function is trivial (object.integerProperty comparison). -- Gwynne ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/andrew_a_james%40yahoo.com This email sent to andrew_a_ja...@yahoo.com ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Use of KVC Array operators
On Mar 12, 2010, at 12:19 PM, Eli Bach wrote: On Mar 12, 2010, at 9:58 AM, Alexander Spohr wrote: what is your understanding of KVC? That it wouldn't do this merging of set's automatically. And I did just try it, and got a binding error: Cocoa Bindings: Error setting value for bound property instanceOfA of object controllerclass: 0x100675780: [_NSFaultingMutableSet 0x1006eab90 addObserver:forKeyPath:options:context:] is not supported. Key path: relationC I figured it would be something like this, which is why I was looking at the @unionOfSets operator in particular (as that's exactly what this is, a union of all sets of relationC objects from a set of relationB objects. And to follow up, I tried both instanceo...@unionofsets.relationb.relationc and instanceofa.relatio...@unionofsets.relationc and as an NSArrayControllers array binding [as the documentation says that @unionOfSets returns an array], and both resulted in a binding error at runtime. Eli ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Better sorting using threads?
On Fri, Mar 12, 2010 at 11:55 AM, Andrew James andrew_a_ja...@yahoo.com wrote: I've made the assumption that NSArray wraps an old school contiguous C-style array ( ala C++ std:::vector ) This assumption is false. --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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Better sorting using threads?
On 12 Mar 2010, at 20:20, Kyle Sluder wrote: On Fri, Mar 12, 2010 at 11:55 AM, Andrew James andrew_a_ja...@yahoo.com wrote: I've made the assumption that NSArray wraps an old school contiguous C-style array ( ala C++ std:::vector ) This assumption is false. There was a good analysis of NSArrays at http://ridiculousfish.com/blog/archives/2005/12/23/array/ Cheers, Chris ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Setting cursor for subview of NSTextView
I have a custom NSTextAttachmentCell that does its work by adding subviews to the NSTextView (e.g. NSButtons). This works fine. What I can't get to work is cursor handling; I always get an arrow cursor when the mouse is over my views. I overwrite resetCursorRects, like this: - (void) resetCursorRects { [super resetCursorRects]; [self addCursorRect:[self bounds] cursor:[NSCursor pointingHandCursor]]; } This doesn't help. Getting desperate, I tried implementing mouseMoved:, but it's not even called (I made sure that my window has setAcceptsMouseMovedEvents: set to YES). Any ideas what else to try, or how to debug what's going on? Setting breakpoints at [NSCursor set] or [NSCursor arrowCursor] didn't get me very far yet. Thanks, Stefan -- Stefan Haller Berlin, Germany http://www.haller-berlin.de/ ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Clicking on an NSColorWell
How can I intercept or get notified when a user clicks on an NSColorWell? OSX 10.6.2 ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSPredicateEditorRowTemplate and dynamic templateViews
Hi everyone, I'm trying to build a custom predicate editor row template that lets me do predicates like in the last 30 days or since {aDate}. For the simple date comparison, I'm returning an NSDatePicker as the third view in my templateViews. My problem is that I only want to return the NSDatePicker if the operator is =, !=, , =, , or =. If the operator is in the last (a custom operator), I want to return 4 template views: the first two being the standard keypath + operator views, but the last two being an NSTextField (with NSNumberFormatter attached) and an NSPopUpButton (with the units: days, weeks, months, etc). I thought that I'd just be able to check which item was selected in the operators popup and return the appropriate views based on the current operator. Unfortunately, it seems like the predicateEditor invokes templateViews *before* the operator actually changes. In other words, if the operator is =, and I switch it to =, then when templateViews is invoked, the operators popup still says =, and won't say = until it's changed again. So my question is this: how can I dynamically modify my row's templateViews to accurately reflect the current operator? I *could* post a notification from the RowTemplate that the editor needs redrawing, and then have my controller capture that notification and invoke reloadPredicate on my predicate editor, but that seems like a really hackish work-around. Any recommendations? (for an example of what I'm describing, try creating a new smart playlist in iTunes and fiddling around with the operators corresponding to the Date Added attribute) Thanks! Dave 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Key-Value Observing speed
On Mar 12, 2010, at 9:35 AM, Gwynne Raskind wrote: While profiling a project I'm working on, I found that while most of my time was being spent in glFlush() (which is completely expected for an OpenGL-based game), a non-trivial amount of time is being spent in dozens of KVO internal methods and functions. Most especially, I noticed that KVO (or possibly the KVC beneath it) makes heavy use of NSInvocation-based forwarding, which is known to be the slowest possible code path for message dispatch. KVO is central to my code's structure; I rely on it for everything to know what everything else is doing without sprinkling manual notifications all over the code. Is there any way to trick the runtime into taking some faster code paths? It's really troublesome to see property setter methods taking up almost as much total time as the audio converter thread in Instruments. Would it help if my properties were sets of integers instead of structures (specifically, NSPoint and NSRect are used quite a bit)? Would it be just blindly insane to think that a NSRectObject would be faster somehow than a plain NSRect because of the structure return trickery the runtime has to do? And if there's nothing I can do with Apple's KVO, is it even remotely realistic to consider writing my own quickie version of KVO that takes faster paths since I can tweak it for my uses? (Side note, Michael Ash's MAKVONotificationCenter has been a panacea for all manner of minor issues I've had with the KVO implementation, kudos Mike!) Please, no one say I shouldn't be writing a game with Objective-C; KVO is the only thing that's tripped me up speed-wise about it. (Well, that and the audio threads doing a heck of a lot of sound processing, I keep wondering if I can put my WAV files into some format that requires less CA conversion or whether it's NSSound forcing that on me...) -- Gwynne I think KVO only uses NSInvocation when setting or getting non-standard aggregate types. So if your property is any primitive C type, any ObjC object, or an NSPoint, NSRect, NSRange, or NSSize, then it will not use NSInvocation. If it's a custom struct it will. Does that seem plausible based on what your property types are? If not, it would be helpful to post a backtrace for the call to +[NSInvocation invocationWithMethodSignature:], so we can figure out what's happening. -Peter ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSPredicateEditorRowTemplate and dynamic templateViews
On Mar 12, 2010, at 1:47 PM, Dave DeLong wrote: Hi everyone, I'm trying to build a custom predicate editor row template that lets me do predicates like in the last 30 days or since {aDate}. For the simple date comparison, I'm returning an NSDatePicker as the third view in my templateViews. My problem is that I only want to return the NSDatePicker if the operator is =, !=, , =, , or =. If the operator is in the last (a custom operator), I want to return 4 template views: the first two being the standard keypath + operator views, but the last two being an NSTextField (with NSNumberFormatter attached) and an NSPopUpButton (with the units: days, weeks, months, etc). I thought that I'd just be able to check which item was selected in the operators popup and return the appropriate views based on the current operator. Unfortunately, it seems like the predicateEditor invokes templateViews *before* the operator actually changes. In other words, if the operator is =, and I switch it to =, then when templateViews is invoked, the operators popup still says =, and won't say = until it's changed again. So my question is this: how can I dynamically modify my row's templateViews to accurately reflect the current operator? I *could* post a notification from the RowTemplate that the editor needs redrawing, and then have my controller capture that notification and invoke reloadPredicate on my predicate editor, but that seems like a really hackish work-around. Any recommendations? (for an example of what I'm describing, try creating a new smart playlist in iTunes and fiddling around with the operators corresponding to the Date Added attribute) Thanks! What you want to do here is to create two separate templates. One looks like this: [Creation Date, Modification Date] [=, !=, , =, , =] {NSDatePicker} The other looks like this: [Creation Date, Modification Date] [in the last] {NSTextField} [days, weeks, months] The first template is responsible for predicates with the standard operators, and the second one is responsible for predicates with the custom operator. At runtime, NSPredicateEditor will merge the templates together, and the second popup will show a union of all the operators of your date templates. Hope that helps, -Peter ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Clicking on an NSColorWell
Subclass and override mouseDown: - however if you're trying to intercept right before the color panel is shown, or a drag starts, that may be trickier. What are you trying to do generally? On Mar 12, 2010, at 1:30 PM, Jonathon Kuo wrote: How can I intercept or get notified when a user clicks on an NSColorWell? OSX 10.6.2 ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/kainjow%40kainjow.com This email sent to kain...@kainjow.com ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Clicking on an NSColorWell
I need to generate an ad-hoc number of color swatches in a floating window so that when a user clicks on one of them, the 'active' color of a stylus will change to that color. Most likely NSColorWell is not the right tool for the job... On Mar 12, 2010, at 2:10 PM, Kevin Wojniak wrote: Subclass and override mouseDown: - however if you're trying to intercept right before the color panel is shown, or a drag starts, that may be trickier. What are you trying to do generally? On Mar 12, 2010, at 1:30 PM, Jonathon Kuo wrote: How can I intercept or get notified when a user clicks on an NSColorWell? OSX 10.6.2 ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/kainjow%40kainjow.com This email sent to kain...@kainjow.com ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSPredicateEditorRowTemplate and dynamic templateViews
This seems so obvious in retrospect that I can't believe I didn't think of that. Thank you so much! Dave On Mar 12, 2010, at 2:57 PM, Peter Ammon wrote: What you want to do here is to create two separate templates. One looks like this: [Creation Date, Modification Date] [=, !=, , =, , =] {NSDatePicker} The other looks like this: [Creation Date, Modification Date] [in the last] {NSTextField} [days, weeks, months] The first template is responsible for predicates with the standard operators, and the second one is responsible for predicates with the custom operator. At runtime, NSPredicateEditor will merge the templates together, and the second popup will show a union of all the operators of your date templates. Hope that helps, -Peter 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Use of KVC Array operators
Am 12.03.2010 um 21:06 schrieb Eli Bach: On Mar 12, 2010, at 12:19 PM, Eli Bach wrote: And I did just try it, and got a binding error: Cocoa Bindings: Error setting value for bound property instanceOfA of object controllerclass: 0x100675780: [_NSFaultingMutableSet 0x1006eab90 addObserver:forKeyPath:options:context:] is not supported. Key path: relationC This sounds like someone tries to SET the value. Not just to read it. That might break. I figured it would be something like this, which is why I was looking at the @unionOfSets operator in particular (as that's exactly what this is, a union of all sets of relationC objects from a set of relationB objects. And to follow up, I tried both instanceo...@unionofsets.relationb.relationc and instanceofa.relatio...@unionofsets.relationc and as an NSArrayControllers array binding [as the documentation says that @unionOfSets returns an array], and both resulted in a binding error at runtime. Maybe you can not bind that way. I have more experience using KVC than KVO. KVC should work that way. Sorry to have bothered you, atze ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Key-Value Observing speed
On Mar 12, 2010, at 4:52 PM, Peter Ammon wrote: While profiling a project I'm working on, I found that while most of my time was being spent in glFlush() (which is completely expected for an OpenGL-based game), a non-trivial amount of time is being spent in dozens of KVO internal methods and functions. Most especially, I noticed that KVO (or possibly the KVC beneath it) makes heavy use of NSInvocation-based forwarding, which is known to be the slowest possible code path for message dispatch. I think KVO only uses NSInvocation when setting or getting non-standard aggregate types. So if your property is any primitive C type, any ObjC object, or an NSPoint, NSRect, NSRange, or NSSize, then it will not use NSInvocation. If it's a custom struct it will. Does that seem plausible based on what your property types are? If not, it would be helpful to post a backtrace for the call to +[NSInvocation invocationWithMethodSignature:], so we can figure out what's happening. You're right; the specific call that's causing the worst speed issues is returning a property typed with this structure: typedef struct { int32_t x, y; } IntegerPoint; It's not necessarily feasible to switch this to an NSPoint; it means digging up every point in the code that relies on signed 32-bit integer math and doing manual typecasting (or calling lround()) away from CGFloat. If there's no way to cheat KVO into doing this sanely, I'll resign myself to it, but I kinda hope there's something a little less annoying. (It's even more annoying because it *was* an NSPoint in a much earlier iteration of the code and I changed it because it simplified the code in two dozen places, and because the property in question is integer and doesn't need the slower floating-point instructions to manipulate it.) -- Gwynne ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Key-Value Observing speed
On Mar 12, 2010, at 2:41 PM, Gwynne Raskind wrote: You're right; the specific call that's causing the worst speed issues is returning a property typed with this structure: typedef struct { int32_t x, y; } IntegerPoint; It's not necessarily feasible to switch this to an NSPoint; it means digging up every point in the code that relies on signed 32-bit integer math and doing manual typecasting (or calling lround()) away from CGFloat. If there's no way to cheat KVO into doing this sanely, I'll resign myself to it, but I kinda hope there's something a little less annoying. Perhaps you can pack it in and out of a 64-bit integer? KVO might handle int64_t natively. -- 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Forcing text layout
Hello Keith! - (void)forceInitialLayout { NSInteger charIndex = (5 [[self textStorage] length] ? [[self textStorage] length] : 5); if (charIndex 0) { charIndex -= 1; [layoutManagerlocationForGlyphAtIndex:charIndex]; You shouldn't play loose which character/glyph indexes. I'm sure you know, but the mapping between chars/glyphs is arbitrary and your method could theoretically trigger an out-of-bounds exception. In practice it probably won't because I believe the Cocoa typesetter always produces more glyphs than characters (eg: inserting null glyphs as padding). That point aside, I've also experienced issues with when forcing layout to a specific character index. Notably that the the mapping from characters to glyphs doesn't seem stable until layout is complete. I've seen -[NSLayoutManager numberOfGlyphs] change before/ after layout! Perhaps the TextEdit code you quoted fails for that reason, eg: the mapping from the final character index (the image attachment) to its corresponding glyph changes after layout finishes. My solution was to conditionally use -[NSLayoutManager ensureLayoutForCharacterRange:] when running on Leopard or later. That punts the problem entirely to Apple to solve. Another thing to check: do you have discontinuous layout enabled? I never did, but perhaps that's a factor for you. ~Martin ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: 10.6 Base, 10.5 Target, runs fine on everything except Intel 10.5 [KIND OF SOLVED]
Thanks to everyone for their suggestions, particularly Greg Parker for the unambiguous clarification. While the safest approach is to use NSClassFromString to ensure that you can run in 64 bit on 10.5, I opted not to do that because it's not enough to actually get all 64-bit apps to work on 10.5, and it also has the downside of essentially requiring frequent testing on 10.5 Intel to make sure you didn't forget something - I'm not big on relying on humans to prevent errors, especially me. In my info,plist I force Leopard to run in 32 bit: LSMinimumSystemVersionByArchitecture x86_64 10.6.0 which results in everything running fine on all platforms, and solves an issue involving System Configuration as well: The issue involves the System Configuration and IOKit frameworks. If you use attempt to use certain functions from the System Configuration Framework in a x86_64 application on 10.5.8, you will get this crash report: - Date/Time: 2010-03-09 16:37:05.849 -0800 OS Version: Mac OS X 10.5.8 (9L31a) Report Version: 6 Anonymous UUID: 27FDECB3-E71F-4ED5-9E76-49DA5B513E3E Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0002, 0x Crashed Thread: 0 Dyld Error Message: Symbol not found: _SCDynamicStoreCreate Referenced from: /Users/smykytyn/Desktop/TEST.app/Contents/MacOS/TEST Expected in: /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit If you do an nm on the System Configuration and IOKit frameworks in the 10.5 and 10.6 SDKs, you will see that some SCF functions in the 10.6 SDK are shown in both frameworks, but not in 10.5 IOKit: Last login: Wed Mar 10 08:39:27 on console SM-MBP:~ smykytyn$ nm /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/IOKit.framework/IOKit | grep Dynamic SM-MBP:~ smykytyn$ nm /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/IOKit.framework/IOKit | grep Dynamic 0001f47f T _SCDynamicStoreCopyMultiple 0001f422 T _SCDynamicStoreCopyValue 0001f39d T _SCDynamicStoreCreate 0001f330 T _SCDynamicStoreCreateRunLoopSource 0001f582 T _SCDynamicStoreKeyCreate 0001f2c5 T _SCDynamicStoreKeyCreatePreferences 0001f1af T _SCDynamicStoreNotifyValue 0001f264 T _SCDynamicStoreSetNotificationKeys 0001f203 T _SCDynamicStoreSetValue The Growl people had an obscure reference to this about building for 64-bit using the 10.5 SDK as their workaround, although I can't find it right now. Perhaps there is some magic obvious solution to get all this to work correctly, but for now I'm restricting Leopard to 32-bit as I need to use these things. On Mar 9, 2010, at 3:25 PM, Greg Parker wrote: On Mar 9, 2010, at 2:57 PM, Steve Mykytyn wrote: I know all about separating 10.6 from 10.5 stuff. The problem is: I've been testing on a 10.5 PPC machine, where everything works fine. On 10.5 Intel, it does not finish starting up, just crashes out. Never gets anywhere that I would use something 10.6 related. Trying to be as clear as possible: 10.6 Intel Snow Leopard - works fine 10.5 Intel Leopard - crashes complaining about NSRunningApplication 10.5 PPC Leopard - works fine Even if the startup sequence for an app was different between PPC and Intel, I'd expect to eventually crash out on both PPC and Intel if it was something I'm doing in the source code. I'm guessing that you crash on 10.5/Intel/Leopard/64-bit and do not crash on 10.5/Intel/Leopard/32-bit. If you write anything like this and run on a system where the class is not present, you will crash on 64-bit but may or may not crash on 32-bit: // BAD [NSRunningApplication someMethod]; If NSRunningApplication may be absent at runtime, then you must not refer to it directly, ever. You must use NSClassFromString() everywhere: // GOOD Class nsRunningApplicationClass = NSClassFromString(@NSRunningApplication); [nsRunningApplicationClass someMethod]; -- 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Clicking on an NSColorWell
Try the AnimatedTableView example. Feel free to post questions after you run it. It has a custom mini color picker thingy. corbin On Mar 12, 2010, at 2:17 PM, Jonathon Kuo wrote: I need to generate an ad-hoc number of color swatches in a floating window so that when a user clicks on one of them, the 'active' color of a stylus will change to that color. Most likely NSColorWell is not the right tool for the job... On Mar 12, 2010, at 2:10 PM, Kevin Wojniak wrote: Subclass and override mouseDown: - however if you're trying to intercept right before the color panel is shown, or a drag starts, that may be trickier. What are you trying to do generally? ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Key-Value Observing speed
On Mar 12, 2010, at 3:41 PM, Gwynne Raskind wrote: You're right; the specific call that's causing the worst speed issues is returning a property typed with this structure: typedef struct { int32_t x, y; } IntegerPoint; It's not necessarily feasible to switch this to an NSPoint; it means digging up every point in the code that relies on signed 32-bit integer math and doing manual typecasting (or calling lround()) away from CGFloat. If there's no way to cheat KVO into doing this sanely, I'll resign myself to it, but I kinda hope there's something a little less annoying. (It's even more annoying because it *was* an NSPoint in a much earlier iteration of the code and I changed it because it simplified the code in two dozen places, and because the property in question is integer and doesn't need the slower floating-point instructions to manipulate it.) Could you cheat by kvo-ing it as a uint64 [maybe by unioning the struct to make sure it gets 8-byte aligned as necessary]? Eli ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Use of KVC Array operators
On Mar 12, 2010, at 3:40 PM, Alexander Spohr wrote: Maybe you can not bind that way. I have more experience using KVC than KVO. KVC should work that way. Sorry to have bothered you, atze It's not a problem. In retrospect, doing this would mean that KVO would need to automagically observe two 'levels' for changes, which seems to me to be unlikely for KVO to do. I've decided to short-circuit the problem by adding a direct relation from instanceA to relationC. Eli ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Setting cursor for subview of NSTextView
I have a custom NSTextAttachmentCell that does its work by adding subviews to the NSTextView (e.g. NSButtons). This works fine. What I can't get to work is cursor handling; I always get an arrow cursor when the mouse is over my views. I overwrite resetCursorRects, like this: ... This doesn't help. Getting desperate, I tried implementing mouseMoved:, but it's not even called Overriding mouseMoved is unfortunately required if you want to customize the mouse cursor in NSTextView (see this post by the helpful Mr Davidson). However, as the docs state, your view must be first responder in order to receive mouseMoved events. Have you checked that? ~Martin ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Key-Value Observing speed
On 12 Mar 2010, at 22:41, Gwynne Raskind wrote: On Mar 12, 2010, at 4:52 PM, Peter Ammon wrote: While profiling a project I'm working on, I found that while most of my time was being spent in glFlush() (which is completely expected for an OpenGL-based game), a non-trivial amount of time is being spent in dozens of KVO internal methods and functions. Most especially, I noticed that KVO (or possibly the KVC beneath it) makes heavy use of NSInvocation-based forwarding, which is known to be the slowest possible code path for message dispatch. I think KVO only uses NSInvocation when setting or getting non-standard aggregate types. So if your property is any primitive C type, any ObjC object, or an NSPoint, NSRect, NSRange, or NSSize, then it will not use NSInvocation. If it's a custom struct it will. Does that seem plausible based on what your property types are? If not, it would be helpful to post a backtrace for the call to +[NSInvocation invocationWithMethodSignature:], so we can figure out what's happening. You're right; the specific call that's causing the worst speed issues is returning a property typed with this structure: typedef struct { int32_t x, y; } IntegerPoint; It's not necessarily feasible to switch this to an NSPoint; it means digging up every point in the code that relies on signed 32-bit integer math and doing manual typecasting (or calling lround()) away from CGFloat. If there's no way to cheat KVO into doing this sanely, I'll resign myself to it, but I kinda hope there's something a little less annoying. (It's even more annoying because it *was* an NSPoint in a much earlier iteration of the code and I changed it because it simplified the code in two dozen places, and because the property in question is integer and doesn't need the slower floating-point instructions to manipulate it.) What options are you using to observe this property? What if you have an additional method you bind to that returns an IntegerPoint already wrapped up in an NSValue or similar? ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Better sorting using threads?
Just a heads-up to say that when I created an NSMutableDictionary on the main thread and then tried to mutate it in a subthread, Snow Leopard threw an exception (trying to mutate a non-mutable object, or somesuch). I was, of course, protecting the mutable dictionary against reentrancy problems and the same code worked fine on Leopard and Tiger. I guess Apple think it's dangerous to let us play with the sharp toys... Paul Sanders ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTableView _dataSourceValueForColumn:row: failure
On Mar 11, 2010, at 7:55 PM, Alexander Bokovikov wrote: On 11.03.2010, at 23:25, Corbin Dunn wrote: http://www.corbinstreehouse.com/blog/2008/08/your-most-important-breakpoint-in-cocoa/ I've done what was told there. No difference. I just get EXC_BAD_ACCESS in XCode status line and debugger's call stack list shows: objc_msgSend - [NSTableView _dataSourceValueForColumn:row: ] and a long chain is below, but there are no my project lines there. All lines are from Cocoa itself. It looks like the window requires for update after dataSource is already released. it still could be caused by something you did. It is hard to say! I'd have to see the bt (like I mentioned earlier). This is how I call the modal window: - (void) doModalWnd{ MyWnd *wnd = [[MyWnd alloc] init]; [[NSApplication sharedApplication] runModalForWindow:[wnd window]]; [wnd release]; } - (IBAction) myBtnClick:(NSButton *)sender { [self performSelector:@selector(doModalWnd) withObject:nil afterDelay:0]; } There is such code within MyWnd.m: - (void)windowWillClose:(NSNotification *)notification { [[NSApplication sharedApplication] stopModalWithCode:NSCancelButton]; } Is there anything criminal here? something's causing something to redraw the table after your datasource was dealloced. Just call [tableView setDatasource:nil] in your datasourc'es dealloc. That will probably fix the issue. .corbin Thanks. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [NSTableview] can't make selected text stay black
Please don't override the private method. Your app is likely to break if you do so. Your solution was perfect. (It didn't work at first, but that's because I had somehow left HighlightStyle as source list in IB while I was trying everything. Per your note, the first thing I checked then perfection.) As you mention, overriding -highlightSelctionInClipRect is unneeded. I also can get away with leaving out the [cell setTextColor:[NSColor blackColor]] as long as I set the background style -- but I'm testing on 10.6 and who knows about 10.5 and it can't hurt. Thanks for the pointer. A five-minute task turned out to be anything but... Kent On Tue, Mar 9, 2010 at 8:37 AM, Keith Blount keithblo...@yahoo.com wrote: Hi, Actually the only way I know of doing this pre-10.6 is to override NSTableView's private _highlightColorForCell: method to return nil. Even if you override -highlightSelectionInClipRect: to do nothing, the cell drawing will still use the highlight colour returned from this private method. If overriding this fixed the problem, then the issue isn't the table drawing the highlight, but the cell. override this in NSCell and return nil: - (NSColor *)highlightColorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView; It would be apparent to see that this is the problem by looking at it and seeing blue around just the cells, and not between columns/rows (ie: intercellSpacing). -corbin ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [NSTableview] can't make selected text stay black
P.S. I'm hesitant about mentioning private methods here, but I don't think there's another way of doing it - I filed an enhancement request for this method to be made public back in April '06, ID#4521167, so please do the same if you think it would be useful. I'm CC'ing Corbin so he can straighten me out on the private method thing if this is totally the wrong advice, but it works for me. :) Thank you for logging the bug -- I do realize we could make this better. Currently, there is a way to do it (override highlightColorWithFrame:), so adding the requested method is nice to have, but not essential. corbin ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Key-Value Observing speed
On Mar 12, 2010, at 5:49 PM, Greg Parker wrote: You're right; the specific call that's causing the worst speed issues is returning a property typed with this structure: typedef struct { int32_t x, y; } IntegerPoint; It's not necessarily feasible to switch this to an NSPoint; it means digging up every point in the code that relies on signed 32-bit integer math and doing manual typecasting (or calling lround()) away from CGFloat. If there's no way to cheat KVO into doing this sanely, I'll resign myself to it, but I kinda hope there's something a little less annoying. Perhaps you can pack it in and out of a 64-bit integer? KVO might handle int64_t natively. But then I'm back to changing every place in the code that looks at this property :). On Mar 12, 2010, at 6:21 PM, Mike Abdullah wrote: What options are you using to observe this property? What if you have an additional method you bind to that returns an IntegerPoint already wrapped up in an NSValue or similar? My options are 0; I don't need old or new values, or initial or prior notifications :). Is the cost of creating an autoreleased NSValue (there's a category on NSValue to wrap this struct, so that part's trivial at least) and extracting its value less than that of taking an NSInvocation? And that still doesn't solve taking apart the code :). Lots of good ideas, but it sounds so far like my best bet is to just go back to an NSPoint, since it looks like I'll have to change everything in the code that uses it anyway. -- Gwynne ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Problem with save as and freed managed object context
Further information: I have just gone through every place in our code where it makes reference to the managed object context (there's only 90 of them thank goodness), and there is nothing there where we either retain or release a managed object context, or use one in a notification or anything like that. I have also found out that the managed object context that is over-released is not the one that I have in my persistent document, so all I can assume is that it is one that is created behind the scenes programmatically during the persistent store migration. I also checked our will/didTurnIntoFault and awakeFromInsert/Fetch to make sure they were clean. Found a few minor problems, but it made no difference. I did find that awakeFromFetch was called during the process of migration, but didn't find out anything else of interest. I also checked for description methods that may have caused faults to fire at the wrong time. I only found one description on one of our managed object classes, and an interesting thing happened when I commented that out - I could not save at all (trying to send an objectID message to an NSNumber). I have not tracked that one down yet. Try running with MallocStackLoggingNoCompact=1 set in the env and using malloc_history to see where an NSManagedObject was allocated and then freed and replaced with an NSNumber. - Ben ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [NSTableview] can't make selected text stay black
Hi Corbin, Many thanks for the clarification, and for providing the official and better way of doing this. Although I will now go through my code an try to do this at the cell level, as obviously I'd much rather my app be future-proofed and avoid using private methods, it's not the ideal perfect world solution in my case - that is, it's a lot more work than being able to do it at the table level. My outline view has many columns (which can be shown and hidden by the user), each with different cell types. I have text cells, button cells, popup button cells, image cells and custom cells - all of which will now need subclassing to override -highlightColorWithFrame:. (I will probably make generic subclasses of NSTextCell, NSPopUpButtonCell etc, each with accessors deciding whether or not to return nil from -highlightColorWithFrame:..., and then may my custom cells subclasses of those.) So although the requested method may not be essential, it would save subclassing every cell type you need to use. :) Thanks again for providing a way of doing this without resorting to private methods, this is something I've been doing for years without realising. All the best, Keith - Original Message From: Corbin Dunn corb...@apple.com To: Keith Blount keithblo...@yahoo.com Cc: cocoa-dev@lists.apple.com; k...@khauser.net Sent: Fri, March 12, 2010 11:29:08 PM Subject: Re: [NSTableview] can't make selected text stay black P.S. I'm hesitant about mentioning private methods here, but I don't think there's another way of doing it - I filed an enhancement request for this method to be made public back in April '06, ID#4521167, so please do the same if you think it would be useful. I'm CC'ing Corbin so he can straighten me out on the private method thing if this is totally the wrong advice, but it works for me. :) Thank you for logging the bug -- I do realize we could make this better. Currently, there is a way to do it (override highlightColorWithFrame:), so adding the requested method is nice to have, but not essential. corbin ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
re: Core Data Spotlight: Record-Level Indexing : Issues?
On Mac OS X v10.6 and later, for non-document-based programs, you can create Spotlight indexes where each record is indexed individually. [1] I interpret this to mean that users can get results for my app's records in their Spotlight searches, the way they get Safari bookmarks and Address Book contacts. Before I get in too deep, I was hoping someone could advise on potential trouble areas: 1. My app is document-based, although in the use-case for which this feature, the user has only one document. I'd like it to index that one. I presume that by non-document-based programs, Apple is actually referring to the store -- in other words, if I provide in my document-based app a non-document-based store, Spotlight can index the records in that store. So I'll copy objects from the user's selected document into the new non-document-based store. Should it work? Does anyone have a more elegant suggestion? I'm not sure what user experience you are trying to effect here. It's sounds like you'd be better off if this part of your app was just not document based at all. The HI guidelines are such that document based apps should not perform row level Spotlight indexing. You can see that is the case empirically with the Spotlight menu. 2. Although you can use your custom managed object classes in the importer, the Core Data External Record daemon ... canâ•˙t use custom managed object classes. All of my managed objects are *subclasses* of NSManagedObject. Is that what they mean by custom managed object classes? It means within the importing code you'll just have NSManagedObjects encapsulating your data. All your persistent properties defined in the model will be accessible, but any custom methods or business logic will not. If so, then the Core Data External Record daemon won't be working for me, but it's optional and only to improve performance. On the other hand, my objects have several dozen properties, only a few of which will be indexed. So if I need to implement another non-document store anyhow, maybe I should copy my objects to simple NSManagedObjects, copying only the few properties which I want indexed by Spotlight or are necessary to act upon a hit. 3. Project currently uses Mac OS 10.5 SDK. If I still want to support 10.5, I need to bite the bullet, read the Cross-Development Programming Guide and configure the project for cross-development, but in the end, Record-Level Indexing should work for my 10.6 users. 10.5 users simply won't get any of my results in their Spotlight searches.Any known gotchas in there? In theory, but since your app is document based, the preferred approach would be to use the whole document spotlight importer. 4. Can't find any sample code. It would be nice to see that Record-Level Indexing has been done? You can create a new project with the template and it should be a functional sample. Both document based and non-document based Core Data projects have templates with spotlight importers. - Ben ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Forcing text layout
Hi Martin, Many thanks for your reply (as always :) ). And d'oh, yes, the glyph/character thing was an oversight - I'm usually very careful about this as I am aware they can be very different, so thanks for picking me up on that. Also thanks for the pointer to -ensureLayoutForCharacterRange: - that works perfectly. So my new method looks like this: - (void)forceInitialLayout { NSInteger charIndex = (2 [[self textStorage] length] ? [[self textStorage] length] : 2); if (charIndex 0) { if(floor(NSAppKitVersionNumber) = NSAppKitVersionNumber10_5) { [layoutManagerensureLayoutForCharacterRange:NSMakeRange(0, charIndex)]; } else { charIndex -= 1; [layoutManagerlocationForGlyphAtIndex:[layoutManagerglyphIndexForCharacterAtIndex:charIndex]]; } } } I think your explanation of the problem is most likely spot on, too - the text container of the glyph is different after layout has finished. I do have noncontiguous layout enabled, but the above seems to work nicely either way. Thanks again! All the best, Keith - Original Message From: Martin Wierschin mar...@nisus.com To: Keith Blount keithblo...@yahoo.com Cc: Cocoa Developers cocoa-dev@lists.apple.com Sent: Fri, March 12, 2010 10:52:07 PM Subject: Re: Forcing text layout Hello Keith! - (void)forceInitialLayout { NSInteger charIndex = (5 [[self textStorage] length] ? [[self textStorage] length] : 5); if (charIndex 0) { charIndex -= 1; [layoutManagerlocationForGlyphAtIndex:charIndex]; You shouldn't play loose which character/glyph indexes. I'm sure you know, but the mapping between chars/glyphs is arbitrary and your method could theoretically trigger an out-of-bounds exception. In practice it probably won't because I believe the Cocoa typesetter always produces more glyphs than characters (eg: inserting null glyphs as padding). That point aside, I've also experienced issues with when forcing layout to a specific character index. Notably that the the mapping from characters to glyphs doesn't seem stable until layout is complete. I've seen -[NSLayoutManager numberOfGlyphs] change before/after layout! Perhaps the TextEdit code you quoted fails for that reason, eg: the mapping from the final character index (the image attachment) to its corresponding glyph changes after layout finishes. My solution was to conditionally use -[NSLayoutManager ensureLayoutForCharacterRange:] when running on Leopard or later. That punts the problem entirely to Apple to solve. Another thing to check: do you have discontinuous layout enabled? I never did, but perhaps that's a factor for you. ~Martin ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: incorrect bitmap date from NSBitmapImageRep from NSDate
Hi, Please go down to the phrase apps are rather fond of hardcoding bitmap formats in the AppKit release notes. http://developer.apple.com/mac/library/releasenotes/cocoa/appkit.html If the latter I suspect that your file is not in the needed format. Does your image have alpha? format is bmp The file format is bmp, but there's also a pixel format, which is the layout of the uncompressed bytes in memory. It is necessary to convert the data to the pixel format that you're telling GL the data is in. You said GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV. The version you have involving NSImage is not safe either, it just happens to work today. -ken On Fri, Mar 12, 2010 at 10:03 AM, Ariel Feinerman arielfap...@gmail.comwrote: 2010/3/12 Alexander Spohr a...@freeport.de Exactly what does not work? The loading? Or the opengl command? texture is corrupted with artifact on the screen and sometimes gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, [image pixelsWide], [image pixelsHigh], GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, [image bitmapData]); take an exception If the latter I suspect that your file is not in the needed format. Does your image have alpha? format is bmp there is of the matter is that messages -initWithCIImage and -initWithFocusedViewRect read bitmap date from offscreen window so image is rendered twice, isn`t it? reference The image in the *ciImage* parameter must be fully rendered before the receiver can be initialized. If you specify an object whose rendering was deferred (and thus does not have any pixels available now), this method forces the image to be rendered immediately. Rendering the image could result in a performance penalty if the image has a complex rendering chain or accelerated rendering hardware is not available. Is the way to get NSBitmapImageRep for OpenGL without offscreen rendering image? atze Am 12.03.2010 um 13:09 schrieb Ariel Feinerman: // not work NSData *data = [NSData dataWithContentsOfFile: filename]; NSBitmapImageRep *image = [[NSBitmapImageRep alloc] initWithData: data]; as opposed to: // works fine NSImage *source = [[NSImage alloc] initWithContentsOfFile: filename]; NSSize size = [source size]; [source lockFocus]; NSBitmapImageRep *image = [[NSBitmapImageRep alloc] initWithFocusedViewRect: NSMakeRect(0.0, 0.0, size.width, size.height)]; [source unlockFocus]; // OpenGL commands gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, [image pixelsWide], [image pixelsHigh], GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, [image bitmapData]); why? as opposed to ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/atze%40freeport.de This email sent to a...@freeport.de -- best regards Ariel ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com This email sent to kenfe...@gmail.com ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Better sorting using threads?
On Mar 12, 2010, at 3:23 PM, Paul Sanders wrote: Just a heads-up to say that when I created an NSMutableDictionary on the main thread and then tried to mutate it in a subthread, Snow Leopard threw an exception (trying to mutate a non-mutable object, or somesuch). I was, of course, protecting the mutable dictionary against reentrancy problems and the same code worked fine on Leopard and Tiger. I guess Apple think it's dangerous to let us play with the sharp toys... mutating method sent to immutable object, you mean? That suggests your NSMutableDictionary object isn't as mutable as you thought. It might not be a thread-related bug. -- 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: 10.6 Base, 10.5 Target, runs fine on everything except Intel 10.5 [KIND OF SOLVED]
On Mar 12, 2010, at 3:52 PM, Steve Mykytyn wrote: While the safest approach is to use NSClassFromString to ensure that you can run in 64 bit on 10.5 There are a lot of hidden pitfalls with targeting 64-bit architectures on Leopard, because there's a lot of UI-related things that should work that either didn't work at all, or cause problems, such as Ink input (which crashed 64-bit apps in early Leopard versions, and just didn't work in 64-bit apps in later versions). A lot of these problems were fixed in Snow Leopard, so I'd recommend just limiting the 64-bit version to Snow Leopard unless you know what you're doing... Nick Zitzmann http://www.chronosnet.com/ ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Better sorting using threads?
No, that would mean that you tried to mutate a non-mutable dictionary. :-) You were getting lucky before in that some dictionary was passed to you that was typed as NSDictionary, but _happened_ to be of the subclass NSMutableDictionary. _That's_ what changed on you. Be aware that if you send -copy to an NSMutableDictionary, you get a non-mutable NSDictionary. -Ken On Fri, Mar 12, 2010 at 3:23 PM, Paul Sanders p.sand...@alpinesoft.co.ukwrote: Just a heads-up to say that when I created an NSMutableDictionary on the main thread and then tried to mutate it in a subthread, Snow Leopard threw an exception (trying to mutate a non-mutable object, or somesuch). I was, of course, protecting the mutable dictionary against reentrancy problems and the same code worked fine on Leopard and Tiger. I guess Apple think it's dangerous to let us play with the sharp toys... Paul Sanders ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com This email sent to kenfe...@gmail.com ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Problem with save as and freed managed object context
Thanks for that suggestion Ben - I haven't come across that method of debugging before. I tried doing it based on the address that I got from the stack trace, but I just seem to get the things relevant to the NSNumber: $ /Developer/usr/bin/malloc_history 12908 0x100e00860 ALLOC 0x100e00860-0x100e0087f [size=32]: thread_7fff70ee2be0 |start | main | NSApplicationMain | objc_msgSend | lookUpMethod | prepareForMethodLookup | _class_initialize | _class_initialize | _class_initialize | +[NSApplication initialize] | +[NSUserDefaults(NSUserDefaults) standardUserDefaults] | -[NSUserDefaults(NSUserDefaults) initWithUser:] | CFPreferencesCopyAppValue | __CFXPreferencesGetSearchListForBundleID | __CFXPreferencesGetSourceForTriplet | CFNotificationCenterAddObserver | _CFXNotificationRegister | CFNumberCreate | _CFRuntimeCreateInstance | malloc_zone_malloc I'm therefore assuming I'll have to get the output from -all_events and dig through that to sort it out? Regards Gideon Try running with MallocStackLoggingNoCompact=1 set in the env and using malloc_history to see where an NSManagedObject was allocated and then freed and replaced with an NSNumber. - Ben ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Key-Value Observing speed
On Mar 12, 2010, at 14:41, Gwynne Raskind wrote: You're right; the specific call that's causing the worst speed issues is returning a property typed with this structure: typedef struct { int32_t x, y; } IntegerPoint; It's not necessarily feasible to switch this to an NSPoint; it means digging up every point in the code that relies on signed 32-bit integer math and doing manual typecasting (or calling lround()) away from CGFloat. If there's no way to cheat KVO into doing this sanely, I'll resign myself to it, but I kinda hope there's something a little less annoying. (It's even more annoying because it *was* an NSPoint in a much earlier iteration of the code and I changed it because it simplified the code in two dozen places, and because the property in question is integer and doesn't need the slower floating-point instructions to manipulate it.) If not necessarily feasible just means changing code in a number of places, I think you should reconsider. When the alternative is baking in a mediocre design compromise, you'll have to live with the consequences forever more. In practice, I'd suggest one of two things (which actually amount to just about the same thing in the end): 1. Make 2 integer properties for the x and y components separately. You can keep the struct property as a kind of convenience property, which means that much of code won't need to be changed. The issue is not that you don't want the struct property, the issue is that you don't want to *observe* the struct property. So, observe the x property or the y property or both instead. 2. Or, add a derived property (which can be transient) whose value is unimportant, but which triggers a KVO notification when the struct property changes. Observe the derived property instead of the struct property. Neither of those approaches requires you to retool *all* your already-written code, just the part that adds and removes observers. #2 won't help if you need to bind to the struct property (and KVO notifications via the binding are part of your performance problem), but #1 should work for that. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Key-Value Observing speed
On 12 Mar 2010, at 23:32, Gwynne Raskind wrote: On Mar 12, 2010, at 5:49 PM, Greg Parker wrote: You're right; the specific call that's causing the worst speed issues is returning a property typed with this structure: typedef struct { int32_t x, y; } IntegerPoint; It's not necessarily feasible to switch this to an NSPoint; it means digging up every point in the code that relies on signed 32-bit integer math and doing manual typecasting (or calling lround()) away from CGFloat. If there's no way to cheat KVO into doing this sanely, I'll resign myself to it, but I kinda hope there's something a little less annoying. Perhaps you can pack it in and out of a 64-bit integer? KVO might handle int64_t natively. But then I'm back to changing every place in the code that looks at this property :). On Mar 12, 2010, at 6:21 PM, Mike Abdullah wrote: What options are you using to observe this property? What if you have an additional method you bind to that returns an IntegerPoint already wrapped up in an NSValue or similar? My options are 0; I don't need old or new values, or initial or prior notifications :). Is the cost of creating an autoreleased NSValue (there's a category on NSValue to wrap this struct, so that part's trivial at least) and extracting its value less than that of taking an NSInvocation? And that still doesn't solve taking apart the code :). Almost certainly faster than NSInvocation. Although potentially more memory-intensive. You could try overriding -valueForKey: to generate an NSValue as a shortcut. Means only adding to your existing code. Lots of good ideas, but it sounds so far like my best bet is to just go back to an NSPoint, since it looks like I'll have to change everything in the code that uses it anyway. -- Gwynne ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net This email sent to cocoa...@mikeabdullah.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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [NSTableview] can't make selected text stay black
Actually, after testing this, does overriding NSCell's -highlightColorWithFrame:controlView: really have the same effect as overriding the _highlightColorForCell: private message? I assume the latter just calls the former, but I must be doing something wrong because overriding -highlightColorWithFrame: didn't have the desired effect for me. Please see the following demo project: http://www.literatureandlatte.com/misc/BlackSelectedTableText.zip Note that in that simple project, MyTextFieldCell overrides -highlightColorWithFrame:controlView: to return nil (and there is an NSLog in there to ensure it is getting called), but although doing so prevents the highlight colour from getting drawn, the text still gets drawn in white (even though the -willDisplayCell: delegate method in MyDocument is setting it to black). Contrast this with uncommenting the _highlightColorForCell: method that returns nil in MyTableView, which has the desired effect of ensuring the text gets drawn in black (which is what the op was after and is the reason I ended up resorting to this private message). Am I missing something obvious? Is there something else that needs to be used in conjunction with this to force the text to be drawn in black even when highlighted? (To put this in context, I use NSOutlineView to provide an OmniOutliner-style outline with a light blue selection, so the text needs to be black even when highlighted given the light highlight, which is custom-drawn.) Many thanks and all the best, Keith - Original Message From: Corbin Dunn corb...@apple.com To: Keith Blount keithblo...@yahoo.com Cc: cocoa-dev@lists.apple.com; k...@khauser.net Sent: Fri, March 12, 2010 11:29:08 PM Subject: Re: [NSTableview] can't make selected text stay black P.S. I'm hesitant about mentioning private methods here, but I don't think there's another way of doing it - I filed an enhancement request for this method to be made public back in April '06, ID#4521167, so please do the same if you think it would be useful. I'm CC'ing Corbin so he can straighten me out on the private method thing if this is totally the wrong advice, but it works for me. :) Thank you for logging the bug -- I do realize we could make this better. Currently, there is a way to do it (override highlightColorWithFrame:), so adding the requested method is nice to have, but not essential. corbin ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data: inverse relationship not updated until next Run Loop
I see. Thanks for both of your responses. Eric On Thu, Mar 11, 2010 at 10:26 PM, Frank Illenberger illenber...@mac.comwrote: In using Core Data, I was under the impression that if I do this: [department addEmployeesObject:employee] // department now has 1 employee [moc deleteObject:employee] Then department will end up with no employees, assuming that the inverse relationship is set correctly. But it turns out within the same run loop, if I inspect [department.employees count], then the value is 1. But in the next run loop, the value becomes 0, which is what it should be. Is my observation accurate or is something wrong? Deletes are propagated at the end of he current event, or at save time, depending how the MOC is configured. But you can call [moc processPendingChanges] directly after the delete to propagate the changes immediately. Frank ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/eylinlist%40gmail.com This email sent to eylinl...@gmail.com ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: performSelector doesn't work for modal window
On Mar 12, 2010, at 10:34 AM, Alexander Bokovikov wrote: Unfortunately NSButton click is called when button is pressed, but not when it is released. This is incorrect. You can click in a button, hold, drag out of the button, and release, and the button won't perform its action. The action is performed when the mouse button is released, if the cursor is still within the button. Therefore any timeconsumming process, executed on the button click, will keep the button pressed. You mean, the button will continue looking like it's depressed. This is intentional. However, the problem is not the appearance of the button that should concern you. It's the fact that the GUI will remain unresponsive for the duration of the time-consuming task. Even if you put it off until after the button redraws itself without the highlight, the GUI will be unresponsive. In fact, in some ways, this is worse. Now, the GUI looks to the user like they can continue to use it, but that's a lie. At least when the button looks depressed, that's a visual clue to the user that the GUI won't be responsive. You probably should either use asynchronous techniques for the time-consuming task or do it on a background thread. Either way, you still need to consider how to represent the ongoing work in the GUI. There's just no simple shortcut to get around doing the right thing. For example, should the user be permitted to click the button again while the time-consuming task is already going? If not, then you'll need to disable the button or switch the GUI so it's no longer present. To avoid it I've decided to use performSelector:withObject:afterDelay: message. This approach works OK for main window, but it doesn't work for a modal popup panel. More exactly, this message is sent only when modal window is closed and NSApplication is returned to the main messages loop. It looks like this is a fundamental Cocoa specifics, though I don't understand it. So, how to send a message to a modal window messages loop? As noted by Paul Sanders, you can use -performSelector:withObject:afterDelay:inModes:. In trying to understand this issue, did you even read the documentation for -performSelector:withObject:afterDelay:? It's all described right there. Regards, 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Dragging rows in NSPredicateEditor
I'm using the NSPredicateEditor control for the first time, and so far it's going well. I notice though that at runtime I'm able to drag an image of each row. What can I do with this drag? I either need to be able to process it in some meaningful way (there may be none for my app) or turn it off. The docs appear not to mention this behaviour anywhere, there's nothing i can see in API and there's no Pboard type that seems to relate to predicates. --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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Dragging rows in NSPredicateEditor
On 13/03/2010, at 2:03 PM, Graham Cox wrote: I notice though that at runtime I'm able to drag an image of each row. What can I do with this drag? I just realised that the drag allows me to reorder the rows - is that its only purpose? I didn't realise that before because it is still draggable even when there is only one row or one row plus the header row of a compound predicate. Shouldn't that drag be suppressed if there is nothing useful for it to do? --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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Key-Value Observing speed
On Fri, Mar 12, 2010 at 5:41 PM, Gwynne Raskind gwy...@darkrainfall.org wrote: On Mar 12, 2010, at 4:52 PM, Peter Ammon wrote: While profiling a project I'm working on, I found that while most of my time was being spent in glFlush() (which is completely expected for an OpenGL-based game), a non-trivial amount of time is being spent in dozens of KVO internal methods and functions. Most especially, I noticed that KVO (or possibly the KVC beneath it) makes heavy use of NSInvocation-based forwarding, which is known to be the slowest possible code path for message dispatch. I think KVO only uses NSInvocation when setting or getting non-standard aggregate types. So if your property is any primitive C type, any ObjC object, or an NSPoint, NSRect, NSRange, or NSSize, then it will not use NSInvocation. If it's a custom struct it will. Does that seem plausible based on what your property types are? If not, it would be helpful to post a backtrace for the call to +[NSInvocation invocationWithMethodSignature:], so we can figure out what's happening. You're right; the specific call that's causing the worst speed issues is returning a property typed with this structure: typedef struct { int32_t x, y; } IntegerPoint; It's not necessarily feasible to switch this to an NSPoint; it means digging up every point in the code that relies on signed 32-bit integer math and doing manual typecasting (or calling lround()) away from CGFloat. If there's no way to cheat KVO into doing this sanely, I'll resign myself to it, but I kinda hope there's something a little less annoying. (It's even more annoying because it *was* an NSPoint in a much earlier iteration of the code and I changed it because it simplified the code in two dozen places, and because the property in question is integer and doesn't need the slower floating-point instructions to manipulate it.) Implement +automaticallyNotifiesObserversForKey: to return NO for that key, then call will/didChangeValueForKey: yourself in the setter. That will avoid the expensive automatic KVO machinery, while allowing you to leave everything else untouched. Mike ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Key-Value Observing speed
On Mar 12, 2010, at 10:22 PM, Michael Ash wrote: You're right; the specific call that's causing the worst speed issues is returning a property typed with this structure: typedef struct { int32_t x, y; } IntegerPoint; It's not necessarily feasible to switch this to an NSPoint; it means digging up every point in the code that relies on signed 32-bit integer math and doing manual typecasting (or calling lround()) away from CGFloat. If there's no way to cheat KVO into doing this sanely, I'll resign myself to it, but I kinda hope there's something a little less annoying. (It's even more annoying because it *was* an NSPoint in a much earlier iteration of the code and I changed it because it simplified the code in two dozen places, and because the property in question is integer and doesn't need the slower floating-point instructions to manipulate it.) Implement +automaticallyNotifiesObserversForKey: to return NO for that key, then call will/didChangeValueForKey: yourself in the setter. That will avoid the expensive automatic KVO machinery, while allowing you to leave everything else untouched. The key is already manually notified, but when I re-ran Instruments to double-check my results... Well, sigh. As people often seem to do with such things, I was misinterpreting what it was telling me. The CPU time's actually in -[NSView setNeedsDisplay:] for some reason. Sorry for the noise. -- Gwynne ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSResponder / acceptsFirstResponder
How does one get a views acceptFirstResponder method called without having to click on the view? If a class subclasses NSResponder so it can get events how does one get an instance of this class in the responder chain? -db ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Key-Value Observing speed
On Fri, Mar 12, 2010 at 2:41 PM, Gwynne Raskind gwy...@darkrainfall.org wrote: (It's even more annoying because it *was* an NSPoint in a much earlier iteration of the code and I changed it because it simplified the code in two dozen places, and because the property in question is integer and doesn't need the slower floating-point instructions to manipulate it.) While floating point is indeed much slow than integer on some processors, many modern processors are specially engineered to do floating point just as fast as integer. Are you targeting Mac OS X or the iPhone? I would expect modern Intel processors to have such fast floating point, but probably not the iPhone's ARM processor. Don Quixote -- Don Quixote de la Mancha quix...@dulcineatech.com http://www.dulcineatech.com Dulcinea Technologies Corporation: Software of Elegance and Beauty. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Which iPhone Program?
Greetings, Earthlings, I just subscribed. I'm just about to sign up for the paid iPhone developer program, but I'm not able to tell from Apple's website which program I should join. Presently I am the only developer, but we have two QA testers who will need to build my code on their own Macs, as well as install onto their devices themselves rather than have me do it for them. The reason is that the three of us are far apart geographically; I also want to ensure that someone else other than just myself can build my source. Both the iPhone Developer Program - Company and iPhone Developer Enterprise Program include the Ability to Create Developer Team. But nowhere can I find any information as to just what that means. I expect the we need licenses for three developer seats. I'll join the Enterprise Program if I really have to, but due to my limited budget, I'd rather join the Company Program if that would suffice. I'd like to suggest to my friends at Apple that they add some more details to the web pages that describe the iPhone developer programs, so that everything which is included with each type of program is made completely explicit. Thank you for any insight you can give me, Don Quixote -- Don Quixote de la Mancha quix...@dulcineatech.com http://www.dulcineatech.com Dulcinea Technologies Corporation: Software of Elegance and Beauty. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com