KVO observing across to-many relationships
I managed to think myself into a corner with KVC/KVO, I was wondering if you can automatically observe across a to-many relationship, I can't see how you could, but cocoa often surprises me. Simple example would be .. I have a instance, race, of a Race object which has an array property 'competitors', it returns an NSArray* of Competitor objects. Each Competitor has a energy property, which is an NSInteger. As the race goes on, energy changes. so Race has this @property( readonly, retain ) NSArray* competitors; and Competitor has this (as well as other properties) @property( readonly, assign ) NSInteger *energy; (you can assume that the insertObject:inCompetitorsAtIndex: and other KVO methods are properly defined and used) I can do this just fine [ race getValueForKeyPath:@competitors.energy ] and I get an NSArray of all the energies of all the competitors in the race. getValueForKeyPath happily iterates the array property, gets each competitor and gets the energy property of it and returns the lot. Now I want to observe stuff, so I added [ race addObserver:self forKeyPath:@competitors options:15 context:NULL ] and all was fine and I got notified nicely as the array of competitors changed (which it does as things start up and people give up etc). then I added, blindly following the same pattern for the key path I'd used in the getValueForKeyPath call, and not really thinking about it a lot [ race addObserver:self forKeyPath:@competitors.energy options:15 context NULL ] and that failed dismally with *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '[NSCFArray 0x1053c0 addObserver:forKeyPath:options:context:] is not supported. Key path: energy' Thinking about it I realise I was asking rather a lot, I wanted KVO to automatically notice changes in the array, register and unregister observers for each of the competitor objects and tell me when their energy level changed, I'm not even quite sure what notification I really expected to get. Anyway, it didn't work. So I was just about to write code which observed the competitors property, then added notifications onto each of the objects for the keypath energy, dealt with additions and deletions from the competitors array etc and I wondered .. this sounds a bit like bindings and that seems to work across paths (ie arrangedObjects.property for table views). Did I miss something here? Is there a way I can get KVO to do this automagically with a @competitors.energy path in addObserver:forKeyPath or is my feeling that KVO doesn't support that correct? If it does, what on earth kind of notifications would I even get as things were added to the competitors array (in a KVO compliant manner of course). I thought perhaps instead of using an NSArray I could write a class which looks like an Array, but overrides addObserverForKeyPath .. remembers what key paths you've asked for, and registers/unregisters them on each object added to or removed from the array. ___ 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 [EMAIL PROTECTED]
NSOutlineView example
Hello, Does anyone know or has good example code showing how to create a NSOutlineView, create a datasource and information to the datasource and display the final result. I am trying to dispaly a NSDictionary in an oultlineview. Thanks Arun ___ 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 [EMAIL PROTECTED]
Re: NSOutlineView example
Have a look at /Developer/Examples/Appkit/OutlineView On 26-Sep-08, at 2:08 PM, Arun wrote: Hello, Does anyone know or has good example code showing how to create a NSOutlineView, create a datasource and information to the datasource and display the final result. I am trying to dispaly a NSDictionary in an oultlineview. Thanks Arun ___ 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/chaitanya%40expersis.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
unrecognized selector sent to instance
Hi, I am having a strange problem of my class declaration. I used to declare some methods of a class in a category, Private. After I have done some refactoring work (basically moving some classes into another framework), it seems those methods declared in the category, Private do not belong to the object anymore. If I load the code in my debugger and try to invoke a method declared as Private, the program receives a doesNotRecognizeSelector error and crashes after receiving the signal SIGTRAP. And if I move those methods into the main implementation of the class, it all works out. Any idea why is that? Thanks for your help. BR, Pan _ See how Windows Mobile brings your life together—at home, work, or on the go. http://clk.atdmt.com/MRT/go/msnnkwxp1020093182mrt/direct/01/___ 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 [EMAIL PROTECTED]
Re: Properties and bindings
It's working now, but I don't understand why. I've got two objects: MyController and MyModel. The interesting parts of the headers look like this: @interface MyModel : NSObject { NSInteger myInteger; } @property(assign) NSInteger myInteger; - (void)changeMyInteger; @end @interface MyController : NSObject { MyModel *model; } @property(assign) MyModel *model; - (IBAction)buttonClick:(id)sender; @end Both properties are synthesized in the implementation files. Here's what buttonClick: does: [self.model changeMyInteger]; A MyController instance is in the nib file, and it creates an instance of MyModel when it awakes. I have a view in the nib with an NSTextField, which is bound to MyController with the key path model.myInteger. I start it up, and the initial value of myInteger (set by MyModel) is in the textfield. But when I click the button, nothing happens: the textfield stays the same. I get buttonClick: to do this instead: [self willChangeValueForKey:@model]; // Thanks Jason! [model changeMyInteger]; [self didChangeValueForKey:@model]; and it works just as it should: the value in the text field changes when I click the button. So now I'm trying to understand why the message to self.model won't work. Doesn't that form do the KVO notification? I suppose I could just surround everything with willChange... and didChange...; but I would like to understand what's going on. dkj ___ 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 [EMAIL PROTECTED]
Re: Image processing in Cocoa
Since you can't use NSImage, you could try Core Image. You can do all that with CGImage in your restricted environment. You can use a bitmap or layer context and then later render it on whatever view you wish. There is a good Core Graphics Quartz tutorial at http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_intro/chapter_1_section_1.html Helder. -- Helder da Rocha ([EMAIL PROTECTED]) Sao Paulo, Brazil Christian Giordano wrote: Thanks Mike, I can't use NSImage (guess why) but a subset. Btw, the problem I have is that I have a view which contains an image. I would like to draw in the image, not in the container view so I need to provide to the draw method the image context. Is this a good approach or all the drawing should happen in the view context? Should I extend the image view and handle the routing internally? Thanks, chr On Wed, Sep 24, 2008 at 11:08 AM, Mike Abdullah [EMAIL PROTECTED] wrote: On 24 Sep 2008, at 10:50, Christian Giordano wrote: Hi guys, is there some good tutorial around about how to manipulate bitmaps in Cocoa? I would be interested on: - copy portion of image over another with a mask (this should be pretty straight forward with quartz2d) [[NSImage alloc] initWithSize:] [image lockFocus] [sourceImage drawAtPoint:point fromRect:imagePortionRect operation:operation fraction:1.0] [image unlockFocus] - apply threshold - apply effects like blur Core Image is your friend Not sure if some of this, like the blur, is recommended to do from an higher level instead of doing it pixel by pixel. In case of the latter, how to get the bytearray with all the pixels info? Thanks a lot, chr ___ 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 [EMAIL PROTECTED] ___ 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/helder.darocha%40gmail.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: lauchd and svnserve
I ran svnserve under launchd on 10.4 but found that using the built in Apache2 and svn_dav mod on 10.5 MUCH easier and less finicky. If anyone in interested in a crudely assembled document about how I did it, you are more than welcome to visit http://steamcode.com/wiki/index.php?title=Turn_on_the_built-in_Subversion_server. I want to eventually turn on https access but I am not there yet. FYI, this is my wiki that I am using to document everything I seem to forget. On Wed, Sep 24, 2008 at 6:52 AM, Patrick Mau [EMAIL PROTECTED] wrote: I hope you don't mind sharing my plist. Please note the 'PathState', that avoids the mentioned mount issues. In addition, I use User/Group settings and decimal umask 23 (027 octal). ?xml version=1.0 encoding=UTF-8? !DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd; plist version=1.0 dict keyDebug/key false/ keyGroupName/key string_svn/string keyKeepAlive/key dict keyPathState/key string/opt/sw/var/lib/svn/string /dict keyLabel/key stringlocal.svnserve/string keyOnDemand/key false/ keyProgramArguments/key array string/opt/sw/bin/svnserve/string string--daemon/string string--foreground/string string--root/string string/opt/sw/var/lib/svn/string string--listen-host/string string0.0.0.0/string /array keyRunAtLoad/key true/ keyUserName/key string_svn/string keyUmask/key integer23/integer /dict /plist On 24.09.2008, at 12:49, Roland King wrote: don't run it like that. the 'd' argument means daemon-ize and it's a requirement of launchd that processes do NOT do that. What's happening is the process is starting, it immediately backgrounds itself, which means the process launchd starts dies, then launchd tries to start it up again but it can't because there is a background daemon process (the one you just started) hogging the socket. Eventually launchd gives up trying to respawn it and the error messages in the console stop, and the daemon one is still there. launchd cannot control processes which do that. You're also clearly trying to start it up too early, so the first few really do actually just die and launchd starts them up again, but it doesn't really know what it's doing. You could run it in foreground mode by changing that '-d' to '--foreground'. That will stop launchd going totally nuts trying to keep starting it up again because it will stay up, and if it does fall down, launchd will correctly start it for you again. however a much better idea is to put it into inetd mode and only start up on demand when someone asks for it, I don't know about you but I don't use my repository very much. For that you need the file which follows. That will start one in inetd mode when someone makes a request on the svn port. In that way the process will be down most of the time which is less strain on the server and it won't start until someone asks for it, which means you shouldn't have all those volume mounting issues. ?xml version=1.0 encoding=UTF-8? !DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd; plist version=1.0 dict keyDisabled/key false/ keyLabel/key stringorg.tigris.subversion.svnserve/string keyProgramArguments/key array string/usr/local/bin/svnserve/string string--inetd/string string--root=Volumes/Development_Current/_CodeRepository/string /array keyServiceDescription/key stringSubversion Standalone Server/string keySockets/key dict keyListeners/key array dict keySockFamily/key stringIPv4/string keySockServiceName/key stringsvn/string keySockType/key stringstream/string /dict /array /dict keyinetdCompatibility/key dict keyWait/key false/ /dict /dict /plist On Sep 24, 2008, at 4:24 PM, René v Amerongen wrote: Dear list Not sure where to put this question, but I did see here more of launchd questions. I got svnserve running with the following plist. ?xml version=1.0 encoding=UTF-8? !DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd; plist version=1.0 dict keyKeepAlive/key dict keyPathState/key dict key/Volumes/Development_Current/_CodeRepository/key true/ /dict /dict keyLabel/key stringsubversion.svnserve/string keyProgramArguments/key array string/usr/local/bin/svnserve/string string-d/string string-r/string string/Volumes/Development_Current/_CodeRepository/string /array keyRunAtLoad/key
objc_msgSend_ptr
i have the following piece of code in my controller class: - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn: (NSTableColumn *)aTableColumn row:(int)rowIndex{ id object = nil; if([tableView columnWithIdentifier:[aTableColumn identifier]] == 1){ object = [[files objectAtIndex:rowIndex] name]; } if([tableView columnWithIdentifier:[aTableColumn identifier]] == 2){ object = (id)[[files objectAtIndex:rowIndex] sizeOfFile]; } return object; } it provides the NSTableView in my app with content. For some reason i cannot assign: object = (id)[[files objectAtIndex:rowIndex] sizeOfFile]; or at least an error occurs i cannot figure out. In the debugger the last item on top of the stack is something like objc_msgSend_ptr. Now files here is an instance of NSMutableArray and the method sizeOfFile belongs to a custom class and returns the size properly. I'm pretty new to Cocoa and Objective-C and being used to java, i'm not quite familiar with memory management (alloc/release/retain etc.). Maybe there is something i'm missing here. I'm running 10.4 Tiger. Thanks in advance. Tilo ___ 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 [EMAIL PROTECTED]
[NSCFNumber intValue]: unrecognized selector
Sorry in advance for a long-winded post, I need help debugging a application crash caused by this unrecognized selector which requires some explanation I've deduced that he crash seems to be something timing related which occurs only at application startup, and only under certain conditions (i.e. reproduce occassionlly by opening an NSOpenPanel modal dialog before the application is fully up and running). When I say the application is fully up and running, I mean a secondary thread has retrieved data from a network source and populated a model class. This secondary thread cyclically updates the data about 8x per second by means of a timer in the secondary thread's run loop. I use Cocoa bindings to display the data in the UI. I'm sure the problem is happening in the bindings, but I'm having trouble finding where. The actual error is : -[NSCFNumber intValue]: unrecognized selector sent to instance 0x815a10 Terminating app due to uncaught exception 'NSInvalidArgumentException The instance is always 0x815a10 every time the application crashes. So if I could figure out what that instance is and where its being used, I could probably fix the problem. That's what I've been unable to do and what I need help with. GDB has got no love for me. The stack backtrace printed in the log (after converting to symbols) shows this: __raiseError (in CoreFoundation) + 331 objc_exception_throw (in libobjc.A.dylib) + 40 -[NSObject doesNotRecognizeSelector:] (in CoreFoundation) + 186 ___forwarding___ (in CoreFoundation) + 892 _CF_forwarding_prep_0 (in CoreFoundation) + 50 -[NSObject(NSKeyValueObservingPrivate) _notifyObserversForKeyPath:change:] (in Foundation) + 508 -[NSController _notifyObserversForKeyPath:change:] (in AppKit) + 248 -[NSController observeValueForKeyPath:ofObject:change:context:] (in AppKit) + 949 NSKVONotify (in Foundation) + 62 -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] (in Foundation) + 546 -[snmpHandler setValue:forIndex:inModel:] (in splNetTREND) (snmpHandler.m:399) -[snmpHandler process_result:apdu:forModel:session:] (in splNetTREND) (snmpHandler.m:283) -[snmpHandler updateVals:forSession:inModel:] (in splNetTREND) (snmpHandler.m:180) -[snmpHandler updateDynamicValsForSession:inModel:] (in splNetTREND) (snmpHandler.m:209) -[snmpSession updateDynamicValsInModel:] (in splNetTREND) (snmpSession.m:97) -[splNetProcess handleTimer:] (in splNetTREND) (splNetProcess.m:180) __NSFireTimer (in Foundation) + 147 CFRunLoopRunSpecific (in CoreFoundation) + 4469 CFRunLoopRunInMode (in CoreFoundation) + 88 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] (in Foundation) + 213 -[NSRunLoop(NSRunLoop) runUntilDate:] (in Foundation) + 93 -[splNetProcess splNetThread:] (in splNetTREND) (splNetProcess.m:95) -[NSThread main] (in Foundation) + 45 __NSThread__main__ (in Foundation) + 308 _pthread_start (in libSystem.B.dylib) + 321 thread_start (in libSystem.B.dylib) + 34 If I could see the [snmpHandler setValue: forIndex: inModel] context in GDB I think I could determine the root of the problem, but the GDB backtrace only shows me this: #0 0x96e160fb in objc_exception_throw () #1 0x93de7ad3 in CFRunLoopRunSpecific () #2 0x93de7cf8 in CFRunLoopRunInMode () #3 0x9420f4a5 in -[NSRunLoop(NSRunLoop) runMode:beforeDate:] () #4 0x9428d8ed in -[NSRunLoop(NSRunLoop) runUntilDate:] () #5 0xc8bb in -[splNetProcess splNetThread:] (self=0x85d950, _cmd=0x8dbe5, arg=0x0) at /Users/steve/Work/src/splNetTREND/ splNetProcess.m:93 #6 0x941daf1d in -[NSThread main] () #7 0x941daac4 in __NSThread__main__ () #8 0x926e36f5 in _pthread_start () #9 0x926e35b2 in thread_start () So my question is how do I figure out what instance 0x815a10 is? Or better yet, is there a way to get GDB to show me the same backtrace as is printed in the log? Thanks in advance for any advice. Sorry again for the long post. Steve ___ 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 [EMAIL PROTECTED]
Loading mechanism with NSAtomicStore
Hello List, As I understand, when using NSAtomicStore, there is only a load method to load the data. It looks like it is an all or nothing operation. However, if I want to load data from a server through some kind of HTTP/XML/Whatever method and only receive a subset of data. How would I implement this? For example, I want to retrieve a list of patients from a hospital system. Obviously, I am not going to load all the patients of the hospital! Now, I can imagine having some king of global variable read by the load method I implement to load only the list of patients I need. But then, how is the faulting handled? A patient will refer to a list of medications, a list of visits, etc... My load method, again, can't deeply fetch all the objects potentially needed because I would end up with all the objects in memory. So I suspect, if a fault is triggered on an object in memory and the object is not (yet) in the local cache, I need my NSAtomicStore (subclass) to be notified to read from my distant store (HTTP/XML...) the missing object(s). Is this possible currently? Any thoughts or solutions for this problem are welcome! Thanks, Alexander ___ 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 [EMAIL PROTECTED]
Re: Converting from Carbon Event Manager to NSTimer
On 25 Sep 2008, at 9:18 am, Dan Birns wrote: I must say, after 20 years of C malloc(), I find retain/release mysterious. It's probably no better or worse than malloc/free, but confusing to me. It seems to me that it has exactly the same advantages/disadvantages, but it's just wildly different. Who does the free()? Who does the retain/release? Pretty much the same problem... retain/release is not the same as malloc/free, and I don't think it will help you to consider them somehow equivalent. FWIW, malloc/free still work normally in Obj-C, retain/release is in addition. [someObject alloc] probably calls malloc() internally. Do read this: http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html When I first encountered retain/release, it was through Hillegasse's book, and his analogy stood me in very good stead when getting my head around retain/release. To paraphrase Hillegasse: An object is like a dog. When you retain it, you attach a leash to it, so it stays with you. When you release it, you unclip your leash. If another person also retains the dog, they attach their own leash to it. As long as at least one person has attached a leash to the dog, the dog is under control and sticks around. When everyone unclips their leashes, the dog goes free - it still exists, but now not on anyone's leash, so it runs off and gets flattened by a bus (thus finally deallocating it). Autorelease is nothing magic either, it's just an automatic leash which unclips itself when the current event completes. In code, the dog is guaranteed to be flattened by a bus when no-one has a leash on it (apologies to dog-lovers), at which point [dog dealloc] is called (which probably internally calls free()). hth, 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 [EMAIL PROTECTED]
Re: NSURLDownload resumeData always nil
Sorry I didn't see your reply earlier due to digest mode... I have confirmed with Wireshark that my test download file: http://google-web-toolkit.googlecode.com/files/gwt-mac-1.5.2.tar.gz includes and ETag. Then I do this: - (void)cancel { [download cancel]; resumeData = [download resumeData]; if (resumeData == nil) { NSLog(@STILL No resume data :(); } [self setDownloading:NO]; } And still the result is no resume data. Any ideas or working examples? Almost forgot additionally, you have to call the Cancel method before checking resumeData, otherwise it's nil. On Sep 23, 2008, at 12:17 PM, [EMAIL PROTECTED] wrote: If the response header does not include an ETag, NSURLDownload will always return a nil resumeData. On Sep 22, 2008, at 10:41 PM, Andrew Zahra wrote: I am experimenting with the resume functionality in NSURLDownload, however I always get nil back when I call resumeData. I have tried a couple of different sites and then tried using wget to get the files. wget resumes the files fine, so I think I am doing something wrong. This is the code in question, which is a modification of the Downloader example supplied by Apple: download = [[WebDownload alloc] initWithRequest:[NSURLRequest requestWithURL:URL] delegate:self]; [download setDeletesFileUponFailure:NO]; resumeData = [download resumeData]; if (resumeData == nil) { NSLog(@No resume data :(); } Any suggestions? thanks, Andrew ___ 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 [EMAIL PROTECTED]
Re: objc_msgSend_ptr
if your sizeOfFile: method is returning an integer, then you should convert it to NSNumber like: object = [NSNumber numberWithInt:[[files objectAtIndex:rowIndex] sizeOfFile]]; hth, Chaitanya On 25-Sep-08, at 5:22 PM, Tilo Villwock wrote: i have the following piece of code in my controller class: - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn: (NSTableColumn *)aTableColumn row:(int)rowIndex{ id object = nil; if([tableView columnWithIdentifier:[aTableColumn identifier]] == 1){ object = [[files objectAtIndex:rowIndex] name]; } if([tableView columnWithIdentifier:[aTableColumn identifier]] == 2){ object = (id)[[files objectAtIndex:rowIndex] sizeOfFile]; } return object; } it provides the NSTableView in my app with content. For some reason i cannot assign: object = (id)[[files objectAtIndex:rowIndex] sizeOfFile]; or at least an error occurs i cannot figure out. In the debugger the last item on top of the stack is something like objc_msgSend_ptr. Now files here is an instance of NSMutableArray and the method sizeOfFile belongs to a custom class and returns the size properly. I'm pretty new to Cocoa and Objective-C and being used to java, i'm not quite familiar with memory management (alloc/release/retain etc.). Maybe there is something i'm missing here. I'm running 10.4 Tiger. Thanks in advance. Tilo ___ 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/chaitanya%40expersis.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
NSNotificationCenter
Within MyController, I call: notifyCenter = [NSNotificationCenter defaultCenter]; [notifyCenter addObserver:self selector:@selector(mySelector:) name:@StatusChanged object:sentNotifyObject]; // We will be the observer and sentNotifyObject will equal the // object encapsulated in the NSNotification passed to the selector. // When this encapsulated [NSNotification object] = nil, the observer // is notified when *any* encapsulated object is sent to the selector. and mySelector looks like: - (void) mySelector:(NSNotification*)sentNotification { MyController *theNotifyObject; theNotifyObject = [sentNotification object]; if (theNotifyObject == myOtherController) { } } = Note that the sent notifyObject encapsulated in the NSNotification is a different controller than the observer, myController. Now, the questions. It appears that everytime I see a need to check the Status, I need to call: - (void) postCalculationStatusChanged:(id)sentNotifyObject { [notifyCenter postNotificationName:StatusChanged object:sentNotifyObject]; } Shouldn't my call to -addObserver automatically monitor StatusChanged rather than my having to -postNotificationName?? John Love ___ 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 [EMAIL PROTECTED]
Re: NSNotificationCenter
On 26 Sep 2008, at 10:14 pm, John Love wrote: Shouldn't my call to -addObserver automatically monitor StatusChanged rather than my having to -postNotificationName?? Well, no. It's not magic - something needs to transmit so that there is something to receive. All the NSNotificationCenter is is a relay station for messages, so that observers don't need intimate knowledge (and hence strong coupling) to the objects they are observing, and vice versa. The reality of sending notifications is that typically objects are designed to blindly transmit all sorts of notifications that the design deems useful. This happened, that will happen and so on. If you have a sender A and a receiver B that set up a notification for some single purpose the advantage of this may seem hard to see, and you certainly don't get much for free. But when you have a complex object with lots of behaviours that other objects might want to observe then the posting of notifications built into the design of object A is great - it means you can simply observe those notifications without revisiting the design of A - a real boon if you don't even have its source code, as with many Cocoa objects. So, to your case: - (void) postCalculationStatusChanged:(id)sentNotifyObject { [notifyCenter postNotificationName:StatusChanged object:sentNotifyObject]; } This violates the spirit and purpose of notifications. Your receiver shouldn't also be forcing the transmitter to transmit, as you are doing here. Instead, the transmitter object should always send a status changed message whenever its status changes. Then the fact that it has changed can be observed by the receiver *and also any other object that might be interested*. What you're doing here is absurd - if you already know the transmitter's status has changed, then you can act on that directly - you don't need to pretend to send a notification to yourself. Somewhere, you should have some code that is part of the 'sentNotifyObject' class that looks like this: - (void) postStatusChanged { [[NSNotificationCenter defaultCenter] postNotificationName:kStatusChangedNotification object:self]; } In almost all cases, whenever you call the -postNotificationName: method of NSNotificationCenter, the object you pass is 'self'. If it's any other, chances are you've done something weird. So, short answer: your design is a bit whiffy. ;) hth, 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 [EMAIL PROTECTED]
Re: Saving an annotated PDF to a flat image
PDFDocument has methods for saving PDF's � since Leopard, annotations are preserved as annotations. I thought that, but if I load annotations into a PDFPage programatically and then save that page's document the annotations are not saved. I load a document from disk, get it's first page (they are all 1 page docs), add the annotations by calling addAnnotation: and then save out the document. Am I missing a stage? Realmac Software Danny Greg, Cocoa Junior We are Realmac Software. We make nice things for Apple Macs. Website: www.realmacsoftware.com Office 4, 100 North Road Brighton, BN1 1YE United Kingdom ___ 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 [EMAIL PROTECTED]
Re: Converting from Carbon Event Manager to NSTimer
On 25.09.2008, at 01:18, Dan Birns wrote: So what happened when I used [NSTimer scheduledTimerWithTimeInterval... I was getting another timer. The result was that my selector would get called maybe 10X more often than intended. This didn't break anything, but impaired performance. So now I simply add a call to [timer invalidate]; before adding a new timer. It's true that we're allocating a new timer with every call, and I'd prefer not to do that, but this seems to be working okay for now. That can't really have happened unless you set the 'repeats' flag on that timer, too. Timers are a special case because they get retained both by the current run loop when they're attached to it, and by you. Hence the 'invalidate' call, which removes it from the run loop again. I must say, after 20 years of C malloc(), I find retain/release mysterious. It's probably no better or worse than malloc/free, but confusing to me. It seems to me that it has exactly the same advantages/disadvantages, but it's just wildly different. Who does the free()? Who does the retain/release? Pretty much the same problem... The main idea behind retain/release is to make shared ownership over a given block of memory and passing memory between scopes easier. This isn't supposed to be saving you from having to do memory management manually. If you want less manual management, turn on the garbage collector. This might be a good opportunity for me to mention Episode 10 of Late Night Cocoa: http://www.mac-developer-network.com/podcasts/latenightcocoa/episode10/index.html where you can hear me going on and on about memory management and the purpose and ideas behind retain/release. Cheers, -- Uli Kusterer The Witnesses of TeachText are everywhere... http://www.zathras.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 [EMAIL PROTECTED]
Re: NSNotificationCenter
On Sep 26, 2008, at 8:14 AM, John Love wrote: Shouldn't my call to -addObserver automatically monitor StatusChanged rather than my having to -postNotificationName?? I wonder if you're confusing notifications with KVO or bindings. Notifications have to be explicitly posted in order for observers to respond to them. --Andy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
problems in runModal in NSOpenPanel used with defaults
Hi, I am writing an utility which needs to open a panel to browse files and select one. - (IBAction)browseClicked:(id)sender { NSOpenPanel *panel = [NSOpenPanel openPanel]; if ([panel runModal]) { NSArray *filenames = [panel filenames]; NSString *filename = [filenames objectAtIndex:0]; if (filename){ printf(\n browseClicked: filename = %s \n, [filename cString]); if ([appToOpenText stringValue] != NULL ){ [appToOpenText setStringValue: filename]; } else printf(\n browseClicked: appToOpenText has NULL value \n); } else printf (\n *** browseClicked: Filename is NULL *** \n); } } The filename chosen is assigned to the textfield. I have used defaults to synchronize this filename and storing it in a pList file. [_defaults setObject: [appToOpenText stringValue] forKey: @AppToOpen ]; [_defaults synchronize]; But whenever I click Browse plIst file is automatically updated with the following junk values What could be the possible reasons to this problem, please help. Thanks, Sparta... ___ 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 [EMAIL PROTECTED]
Fastest color detection in image?
Hi, I'm trying to scan an image for existence of a given color. So I was wondering what the most performing way is to achieve this goal. Basically I want to find out which amount of the given color that image has. Furthermore, are there ways to find all regions of the image having the color? So it would be easy to show the user which parts of the image are matching. Really appreciating any help on this. Thanks Christian ___ 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 [EMAIL PROTECTED]
Re: Properties and bindings
On Sep 24, 2008, at 4:32 PM, D.K. Johnston wrote: - (IBAction)buttonClick:(id)sender; @end Both properties are synthesized in the implementation files. Here's what buttonClick: does: [self.model changeMyInteger]; This method is not KVO compliant (http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueObserving/Concepts/KVOCompliance.html ). I'd guess that the implementation of changeMyInteger is not KVO- compliant for 'integer' either. A MyController instance is in the nib file, and it creates an instance of MyModel when it awakes. I have a view in the nib with an NSTextField, which is bound to MyController with the key path model.myInteger. I start it up, and the initial value of myInteger (set by MyModel) is in the textfield. But when I click the button, nothing happens: the textfield stays the same. Because you're not invoking a KVO-compliant method. I get buttonClick: to do this instead: [self willChangeValueForKey:@model]; // Thanks Jason! [model changeMyInteger]; [self didChangeValueForKey:@model]; Don't do this. You should make sure you're invoking KVO-compliant methods, not sprinkling KVO change notification method invocations throughout your code. and it works just as it should: the value in the text field changes when I click the button. So now I'm trying to understand why the message to self.model won't work. Doesn't that form do the KVO notification? No. Why would it? It's not changing a value. This works because you're telling the object controller that the whole model object has changed, so everything downstream from it is recalculated. I suppose I could just surround everything with willChange... and didChange...; Don't do that. but I would like to understand what's going on. It's all documented in http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueObserving/ . Unless you've opted out of automatic change notification (http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueObserving/Concepts/AutoVsManual.html ), you should simply invoke the relevant set accessor, either directly from your controller or within the body of your changeInteger method: - (IBAction)buttonClick:(id)sender { NSInteger currentValue = model.myInteger; model.myInteger = currentValue + 1; // exactly the same as [model setMyInteger:(currentValue + 1)]; } or - (void)changeMyInteger { self.myInteger = myInteger + 1; // exactly the same as [self setMyInteger:(myInteger + 1)]; } mmalc ___ 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 [EMAIL PROTECTED]
Re: Fastest color detection in image?
On Friday, September 26, 2008, at 09:04AM, Christian Klotz [EMAIL PROTECTED] wrote: I'm trying to scan an image for existence of a given color. So I was wondering what the most performing way is to achieve this goal. You probably want to look into direct-pixel access (there are some code examples out there that show you how) Basically I want to find out which amount of the given color that image has. Furthermore, are there ways to find all regions of the image having the color? So it would be easy to show the user which parts of the image are matching. Sounds like Photoshop's feature of showing non-NTSC colors. I would create a secondary bit-map image. I would then read the first one and for each pixel that matches your criteria, I would add a pixel to the secondary image of a certain color. Such a color could be in a user-preference. I think Photoshop defaults to bright red. Then, when rendering your image, you can optionally composite the secondary image to show the matching pixels. Important: your matching logic should take color spaces into account when comparing values. This actually gets a bit tricky. You may also choose to define a certain amount of slop when comparing actual RGB, HSB, CMYK, etc. values. -- Rick Sharp Instant Interactive(tm) ___ 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 [EMAIL PROTECTED]
Porting 'operator' to Obj-C
Hi there. I am in a process of porting some C++ code to ObjC. How to port the code bellow (operators). Thanks. typedef struct encoding_tag { byte encodings[ 16 ]; ushort count; encoding_tag() { count = 0; } encoding_tag( encoding_tag encoding ) { *this = encoding; } void operator = ( encoding_tag encoding ) { count = encoding.count; for ( int i = 0; i count; i++ ) encodings[i] = encoding.encodings[i]; } bool operator == ( encoding_tag cmp ) { if ( count != cmp.count ) return false; return (*this = cmp); } bool operator != ( encoding_tag cmp ) { return !(*this == cmp); } } ENCODING; ___ 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 [EMAIL PROTECTED]
Re: Porting 'operator' to Obj-C
Objective-C does not support operator overloading. [1, 2] If you're looking to compare equality, the convention is to implement your own isEqual: method that returns a BOOL (YES or NO). HTH, Dave [1] http://borkwarellc.wordpress.com/2007/08/19/objective-c-is-stupid-but-i-still-like-it/ [2] http://theocacao.com/comment/4600 On Sep 26, 2008, at 9:03 AM, Alex Finkel wrote: Hi there. I am in a process of porting some C++ code to ObjC. How to port the code bellow (operators). Thanks. typedef struct encoding_tag { byte encodings[ 16 ]; ushort count; encoding_tag() { count = 0; } encoding_tag( encoding_tag encoding ) { *this = encoding; } void operator = ( encoding_tag encoding ) { count = encoding.count; for ( int i = 0; i count; i++ ) encodings[i] = encoding.encodings[i]; } bool operator == ( encoding_tag cmp ) { if ( count != cmp.count ) return false; return (*this = cmp); } bool operator != ( encoding_tag cmp ) { return !(*this == cmp); } } ENCODING; ___ 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/davedelong%40me.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: Fastest color detection in image?
On Sep 26, 2008, at 10:04 AM, Christian Klotz wrote: Hi, I'm trying to scan an image for existence of a given color. So I was wondering what the most performing way is to achieve this goal. Take a look at the vImage Programming Guide and the associated reference. vImage contains several APIs to do histogram generation. I'm sure one of them will be just perfect for you. Basically I want to find out which amount of the given color that image has. Furthermore, are there ways to find all regions of the image having the color? So it would be easy to show the user which parts of the image are matching. Have you taken a look at any of the Core Image filters? Perhaps something like CIColorCube or one of the compositing filters might be what you need to highlight the region of a selected color. additionally, if you can't find what you need, you can always write your on custom filter using the Core Image Kernal Language. (for more info, see the Core Image Programming Guide) ___ 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 [EMAIL PROTECTED]
Re: Porting 'operator' to Obj-C
On 26 Sep 2008, at 17:03, Alex Finkel wrote: Hi there. I am in a process of porting some C++ code to ObjC. How to port the code bellow (operators). Thanks. snip - operator= is a normal assignment method that takes an NSArray as its argument. Something like the following (untested) code, depending on what the rest of the C++ class looks like: - (void)setEncodings:(NSArray *)encoding { _count = [encoding size]; _encodings = [encoding copy]; } But I wouldn't even have the _count instance variable. It's just as easy to just ask the _encodings array for its size whenever needed. The other methods are left as an exercise to the reader. I originally learned C++ back in the 80's from a guy named Bjarne Stroustrup, but I'd pick Objective C any time. Robert 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 [EMAIL PROTECTED]
Re: objc_msgSend_ptr
That did the trick, thanks a lot. Seems like I need to review a few concepts here. -Ursprüngliche Nachricht- Von: chaitanya pandit [mailto:[EMAIL PROTECTED] Gesendet: Freitag, 26. September 2008 12:25 An: Tilo Villwock Cc: cocoa-dev@lists.apple.com Betreff: Re: objc_msgSend_ptr if your sizeOfFile: method is returning an integer, then you should convert it to NSNumber like: object = [NSNumber numberWithInt:[[files objectAtIndex:rowIndex] sizeOfFile]]; hth, Chaitanya On 25-Sep-08, at 5:22 PM, Tilo Villwock wrote: i have the following piece of code in my controller class: - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn: (NSTableColumn *)aTableColumn row:(int)rowIndex{ id object = nil; if([tableView columnWithIdentifier:[aTableColumn identifier]] == 1){ object = [[files objectAtIndex:rowIndex] name]; } if([tableView columnWithIdentifier:[aTableColumn identifier]] == 2){ object = (id)[[files objectAtIndex:rowIndex] sizeOfFile]; } return object; } it provides the NSTableView in my app with content. For some reason i cannot assign: object = (id)[[files objectAtIndex:rowIndex] sizeOfFile]; or at least an error occurs i cannot figure out. In the debugger the last item on top of the stack is something like objc_msgSend_ptr. Now files here is an instance of NSMutableArray and the method sizeOfFile belongs to a custom class and returns the size properly. I'm pretty new to Cocoa and Objective-C and being used to java, i'm not quite familiar with memory management (alloc/release/retain etc.). Maybe there is something i'm missing here. I'm running 10.4 Tiger. Thanks in advance. Tilo ___ 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/chaitanya%40expersis.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: showing window causes EXC_BAD_ACCESS
I can't think of a single reasonable use case for it An app with many windows, many of which can display multiple instances at a time--they should be released when closed. I'd turn the question around--why do people assume that a single instance of a window can be closed and then re-displayed, especially when the reference to it was obviously not retained properly to begin with. -- Scott Ribe [EMAIL PROTECTED] http://www.killerbytes.com/ (303) 722-0567 voice ___ 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 [EMAIL PROTECTED]
Re: Porting 'operator' to Obj-C
Thanks, but can you point me in the right direction. The code bellow does not build. Am I doing something wrong with the struct? typedef struct dbnames { short Handle; short Version; int Size; intNumEntries; char Name[ 32 ]; dbnames() :Handle(-1), Version ( 0), Size (0), NumEntries ( 0), { Name[0] = '\0'; } dbnames( struct dbnames const other ) :Handle( other.Handle ), Version( other.Version ), Size( other.Size ), NumEntries( other.NumEntries ) { for ( unsigned int i = 0; i sizeof( Name ); i ++ ) { Name[i] = other.Name[i]; } } }; ___ 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 [EMAIL PROTECTED]
NSLevelIndicator - setEnabled not respected
I have a Core Data application, several fields of which are Int16s which are bound to NSLevelIndicators and a NSLevelIndicatorCell. I have some methods that calculate and set the values of these properties in a subclass of NSManagedObject, using old-style accessor methods. I'm aware of the broken nature of the Editable checkbox for NSLevelIndicator and NSLevelIndicatorCell elements in Interface Builder, so I subclassed them, set the UI objects to the subclass, and added the following method: - (void) awakeFromNib { [self setEnabled:NO]; NSLog(@checking isEnabled: %d, [self isEnabled]); } Checking the log, it's returning a value of 0, so it should be disabled, right? Wrong. The level indicators are still responding to mouse events (click, click-and-drag). I've googled for over a week, and I can't find out what I'm missing here. Can anyone shed some light on this? TIA, - Mike --- Michael A. LaMorte In matters of style, swim with the current; In matters of principle, stand like a rock -Thomas Jefferson ___ 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 [EMAIL PROTECTED]
Re: Porting 'operator' to Obj-C
This is C++, not C. You need to be compiling this as Objective-C++, not Objective-C. Easiest way is to change the extension of the file from .m to .mm if you are using Xcode. As an aside, you do not need the typedef in C++. Simply declaring the struct (or class) is enough to declare the type. Jonathan On Sep 26, 2008, at 11:40 AM, Alex Finkel wrote: Thanks, but can you point me in the right direction. The code bellow does not build. Am I doing something wrong with the struct? typedef struct dbnames { short Handle; short Version; int Size; intNumEntries; char Name[ 32 ]; dbnames() :Handle(-1), Version ( 0), Size (0), NumEntries ( 0), { Name[0] = '\0'; } dbnames( struct dbnames const other ) :Handle( other.Handle ), Version( other.Version ), Size( other.Size ), NumEntries( other.NumEntries ) { for ( unsigned int i = 0; i sizeof( Name ); i ++ ) { Name[i] = other.Name[i]; } } }; ___ 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/jprescott12%40comcast.net This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: Use other key than tab to cycle through text fields
On Sep 25, 2008, at 9:18 PM, Graham Cox wrote: On 26 Sep 2008, at 10:24 am, Gerd Knops wrote: I would like to use a key other than tab to advance to the next text field, so that users can use a numeric keypad to enter something like 11-22-33 and have 11, 22 and 33 end up in different text fields. I'd suggest not using a different key from 'Tab', since that's very much hardwired into every Mac user. I don't want to replace it, just duplicate it's functionality for the '-' key. Reason being that there is no tab key on a numeric keypad. Alternative, why not just detect when the field has the required number of characters and move to the next field automatically? For numeric entry this is much more user-friendly. The number of digits in the field is variable. Thanks Gerd ___ 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 [EMAIL PROTECTED]
Re: Causing systemUIServer to update the User Menu for Fast User Switching.
This turned out to be pretty simple. I just needed to send out either com.apple.UserWasRemovedNotification or com.apple.UserWasAddedNotification and the switch screenname list gets updated. E.g. // We need to send the standard OS notification so that the switch screen name list will be updated [[NSDistributedNotificationCenter defaultCenter] postNotificationName:@com.apple.UserWasRemovedNotification object:nil userInfo:nil]; Ken On 9/25/08 2:49 PM, Ken Andrews [EMAIL PROTECTED] wrote: I¹ve got an app that creates users via dscl. The users get created and themselves are set up fine. The problem I have is that the list of users in the fast user switching menu does not get updated. Using the login screen works fine. The user is there just not in the fast user switch pull down. I can make it update by restarting systemUIServer but that is not something I want to do. If I add users from the system prefs they are immediately added to the user list so there must be some method to get the list to update. I send all the same notifications that system prefs sends but they do not seem to help. One thing that I did notice was in SystemUIServer/Content/Resources/Autoload.plist array dict keyid/key integer-10014/integer keymethod/key string_userCanLoad/string keypath/key string/System/Library/CoreServices/Menu Extras/User.menu/string /dict This makes me think that there is some simple way to tell the ui server to update just the user list. Anyone have an idea of what it is? Thanks, 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 [EMAIL PROTECTED]
Re: What does @loader_path refer to when loading ibplugins from a linked-in framework?
Hello Michael, I have tried many things to get my plugin to load automatically in Interface Builder but I still haven't made it. I tried many things before testing something I assumed would work but I realized that even this wasn't enough. I changed DYLD_FALLBACK_FRAMEWORK_PATH to add the folder which contains my MyComponent.framework framework but even this didn't help me load up my plugin. My guess is that either I modified DYLD_FALLBACK_FRAMEWORK_PATH the wrong way, either the problem isn't about the framework not being found. Here is the command line I used: cd /Developer/Applications/Interface\ Builder.app/Contents/MacOS DYLD_FALLBACK_FRAMEWORK_PATH=$DYLD_FALLBACK_LIBRARY_PATH:/Users/gaubut/DevDruide/Sortie/Debug/ ./Interface\ Builder regards -Dalzhim 2008/9/25 Michael Ash [EMAIL PROTECTED] This just sets a shell variable. IB won't see it. Either export it: export DYLD_PRINT_BINDINGS=1 Or set it as part of running the binary: DYLD_PRINT_BINDINGS=1 ./Interface\ Builder 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/dalzhim.mlist%40gmail.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: Use other key than tab to cycle through text fields
On Sep 25, 2008, at 10:37 PM, Ken Thomases wrote: On Sep 25, 2008, at 9:18 PM, Graham Cox wrote: On 26 Sep 2008, at 10:24 am, Gerd Knops wrote: I would like to use a key other than tab to advance to the next text field, so that users can use a numeric keypad to enter something like 11-22-33 and have 11, 22 and 33 end up in different text fields. I'd suggest not using a different key from 'Tab', since that's very much hardwired into every Mac user. Alternative, why not just detect when the field has the required number of characters and move to the next field automatically? For numeric entry this is much more user-friendly. For implementing such a thing, see -[NSWindow selectNextKeyView:]. I know how to do that part. The tricky part is intercepting and filtering the '-' key. given field editors etc. One approach I tried was to implement -validateValue:forKey:error: and intercept the key values of the fields I am interested in, testing for a '-' as last character, removing it and advancing to the next key field. That works (after setting the involved bindings to 'Continuously updates value' and 'Verify immediately'), but for some odd reason when the '-' character is entered that method is called twice, causing it to skip a field. I hoped to avoid having to also add connections for the individual views so that I can find the next key view for the key field in question, but it seems to be the least bothersome approach at that point. Thanks Gerd ___ 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 [EMAIL PROTECTED]
Re: unrecognized selector sent to instance
On Sep 25, 2008, at 4:01 AM, pan xuan wrote: Hi, I am having a strange problem of my class declaration. I used to declare some methods of a class in a category, Private. After I have done some refactoring work (basically moving some classes into another framework), it seems those methods declared in the category, Private do not belong to the object anymore. If I load the code in my debugger and try to invoke a method declared as Private, the program receives a doesNotRecognizeSelector error and crashes after receiving the signal SIGTRAP. And if I move those methods into the main implementation of the class, it all works out. Any idea why is that? Thanks for your help. BR, Pan Perhaps a memory management error somewhere? Try to run your app with NSZombieEnabled (Google for the details) and see what that turns up. j o a r ___ 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 [EMAIL PROTECTED]
Re: [NSCFNumber intValue]: unrecognized selector
On Sep 25, 2008, at 6:22 AM, Steve Rossi wrote: I've deduced that he crash seems to be something timing related which occurs only at application startup, and only under certain conditions (i.e. reproduce occassionlly by opening an NSOpenPanel modal dialog before the application is fully up and running). When I say the application is fully up and running, I mean a secondary thread has retrieved data from a network source and populated a model class. This secondary thread cyclically updates the data about 8x per second by means of a timer in the secondary thread's run loop. I use Cocoa bindings to display the data in the UI. I'm sure the problem is happening in the bindings, but I'm having trouble finding where. In the general case, and with few exceptions, you can't call your UI on non-main threads. This means that you can't drive UI updates based on KVO notifications from non-main threads. Could this be your problem? j o a r ___ 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 [EMAIL PROTECTED]
sending email with attachement from cocoa
Is there a way to use a url request to open mail with all its fields completed but most importantly, contain an image attachement? thx AC ___ 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 [EMAIL PROTECTED]
Re: showing window causes EXC_BAD_ACCESS
On Fri, Sep 26, 2008 at 11:34 AM, Scott Ribe [EMAIL PROTECTED] wrote: I can't think of a single reasonable use case for it An app with many windows, many of which can display multiple instances at a time--they should be released when closed. Sure. By the objects that own them. Them's the rules, after all. I'd turn the question around--why do people assume that a single instance of a window can be closed and then re-displayed, especially when the reference to it was obviously not retained properly to begin with. How was it not retained properly to begin with? The window releases *itself*. Generally the nib owner will continue to own a reference to every window inside. But that won't prevent an object which breaks the rules and does a [self release] from going a way, which is exactly what happens here. People quite correctly assume that if they retain an object (whether explicitly or, in the case of being file's owner of a nib, implicitly) that this object stays alive until they release it. This NSWindow setting breaks that contract. Thus my inability to see its usefulness. As Kyle pointed out, the real problem is that this flag is enabled by default. NSWindow has more than one setting which will completely destroy its functionality in non-obvious ways, but all the other settings are given a sane default in IB. 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 [EMAIL PROTECTED]
Re: problems in runModal in NSOpenPanel used with defaults
Howdy spartan, Oh! A few little tips: On Sep 26, 2008, at 3:11 AM, spartan g wrote: Hi, I am writing an utility which needs to open a panel to browse files and select one. - (IBAction)browseClicked:(id)sender { NSOpenPanel *panel = [NSOpenPanel openPanel]; if ([panel runModal]) { NSArray *filenames = [panel filenames]; NSString *filename = [filenames objectAtIndex:0]; Always check the array length first, or just use [panel filename]; if (filename){ printf(\n browseClicked: filename = %s \n, [filename cString]); Just a side note: most cocoa people move to NSLog, but printf still works. Try: NSLog(@%@, filename); -- much easier! if ([appToOpenText stringValue] != NULL ){ nil is preferred to NULL. [appToOpenText setStringValue: filename]; } else printf(\n browseClicked: appToOpenText has NULL value \n); } else printf (\n *** browseClicked: Filename is NULL *** \n); } } The filename chosen is assigned to the textfield. I have used defaults to synchronize this filename and storing it in a pList file. [_defaults setObject: [appToOpenText stringValue] forKey: @AppToOpen ]; It seems strange to use the user defaults as your model to store objects, but i'm sure there is a reason you do this. [_defaults synchronize]; You probably don't want to hold onto the userdefaults instance as an ivar, and instead always query it with [NSUserDefaults standardUserDefaults]. It may be possible that something is calling resetStandardUserDefaults, and blowing away the old instance. 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 [EMAIL PROTECTED]
Re: NSNotificationCenter
Graham Cox, Andy Lee, et. al: This violates the spirit and purpose of notifications. Your receiver shouldn't also be forcing the transmitter to transmit, as you are doing here. Instead, the transmitter object should always send a status changed message whenever its status changes. Then the fact that it has changed can be observed by the receiver *and also any other object that might be interested*. What you're doing here is absurd - if you already know the transmitter's status has changed, then you can act on that directly - you don't need to pretend to send a notification to yourself. Somewhere, you should have some code that is part of the 'sentNotifyObject' class that looks like this: - (void) postStatusChanged { [[NSNotificationCenter defaultCenter] postNotificationName:kStatusChangedNotification object:self]; } In almost all cases, whenever you call the -postNotificationName: method of NSNotificationCenter, the object you pass is 'self'. If it's any other, chances are you've done something weird. So, short answer: your design is a bit whiffy. ;) I love that word whiffy .. so bloody English, so Rex Harrison. I moved all -postNotificationName:object: to the receiver and so that's done; not only that, it makes sense. I am the observer, so it's the receiver that is responsible for posting or sending changes to the defaultCenter. In addition, maybe Andy is also correct when he said: I wonder if you're confusing notifications with KVO or bindings. Notifications have to be explicitly posted in order for observers to respond to them. I said originally: Shouldn't my call to -addObserver automatically monitor StatusChanged rather than my having to -postNotificationName?? It does, but only when the receiver posts. Having said that, let me restate it, perhaps a little more accurately: I would like to some how bind the observer to the receiver so that every time the receiver changes a parameter, it automatically posts that a change has occurred, without having to explicitly post. I believe that KVO stands for key-value-order .. so obviously I've got a lot of digging to do, starting with Chapter #1, where ever that is. John Love ___ 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 [EMAIL PROTECTED]
Re: sending email with attachement from cocoa
On Sep 26, 2008, at 10:03 AM, Alexander Cohen wrote: Is there a way to use a url request to open mail with all its fields completed but most importantly, contain an image attachement? Not using the frameworks provided by Apple. Your problem, in particular, is that you can't assume that all users are running the same email client. There are some third party attempts at solving this problem - Google. j o a r ___ 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 [EMAIL PROTECTED]
addTrackingRect strangness
Hi Guys, I have a custom view which is set in an NSMenuItem. This view contains 9 rectangles which I would like to track for mouse- over event. I use the the very same method for calculating the size of the rects for drawing and the for defining the tracking rects. What I experience is that events are fired as if the tracking rects are shifted about 4 pixels upwards. Any ideas? Mudi ___ 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 [EMAIL PROTECTED]
[Q] Which mailing list is for the functions like valloc()?
Hello, all. I think I found a bug in the valloc(). However, before reporting it to Apple, I would like to ask if it is really a bug or if anyone also noticed the problem. So, I tried figuring out what mailing list is for, but couldn't determined it. Can it be here, Cocoa-dev, or others like *Darwin-x86* http://lists.apple.com/mailman/listinfo/darwin-x86 or *Darwin-dev* http://lists.apple.com/mailman/listinfo/darwin-dev? 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 [EMAIL PROTECTED]
window controllers and managed object contexts
To avoid cluttering up my main AppController (which had five windows), I've started placing the individual windows into separate xib files. Pre-Core Data (for a regular cocoa app), I would simply set up a window controller, establish a reference to it in the main controller (initWithWindowNibNamed), and load the window when needed. I tried this, but with Core Data, I'm getting a message that I need a managed object context (moc). I know how to get the moc, but I can't figure out who is calling for the moc in the first place. Something inside of the underneath NSWindowController code, I suspect. The window controller's initialization goes fine, as does awakeFromNib. Also, the File's Owner is set to the window controller class. So which method (one called by Cocoa, not me) needs to be overwritten so I can pass the moc to it? Or is there something else entirely going on? 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 [EMAIL PROTECTED]
Re: showing window causes EXC_BAD_ACCESS
I should? Then how do I get the reference back? If windowA is a window outlet in my AppController, then first time around I don't do anything. It is automatically assigned a reference when the window loads, and I can use makeKeyAndOrderFront. But if I choose to automatically release the window on closing, how do I get the variable windowA reassigned to the window? I don't want to reload the entire nib because there may be other things in the nib that don't need to be reloaded On Sep 26, 2008, at 1:33 PM, [EMAIL PROTECTED] wrote: Message: 1 Date: Fri, 26 Sep 2008 10:34:50 -0500 From: Scott Ribe [EMAIL PROTECTED] Subject: Re: showing window causes EXC_BAD_ACCESS To: Michael Ash [EMAIL PROTECTED], Cocoa Developers cocoa-dev@lists.apple.com Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=US-ASCII I can't think of a single reasonable use case for it An app with many windows, many of which can display multiple instances at a time--they should be released when closed. ___ 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 [EMAIL PROTECTED]
Re: window controllers and managed object contexts
On Fri, Sep 26, 2008 at 2:33 PM, Daniel Child [EMAIL PROTECTED] wrote: I tried this, but with Core Data, I'm getting a message that I need a managed object context (moc). I know how to get the moc, but I can't figure out who is calling for the moc in the first place. Something inside of the underneath NSWindowController code, I suspect. The window controller's initialization goes fine, as does awakeFromNib. Also, the File's Owner is set to the window controller class. So which method (one called by Cocoa, not me) needs to be overwritten so I can pass the moc to it? Erm, NSWindowController shouldn't be asking for a MOC. Perhaps whatever NSControllers you have in your nibs haven't had their managedObjectContext bindings fixed? --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 [EMAIL PROTECTED]
Re: Saving an annotated PDF to a flat image
On Sep 26, 2008, at 5:55 AM, Danny Greg wrote: I load a document from disk, get it's first page (they are all 1 page docs), add the annotations by calling addAnnotation: and then save out the document. Am I missing a stage? No, that sounds right — assuming you are saving the PDF document by calling PDFDocument's writeToFile/URL methods. Can you share some swatch of code? John Calhoun—___ 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 [EMAIL PROTECTED]
Re: addTrackingRect strangness
On Sep 26, 2008, at 11:17 AM, Mudi Dandan wrote: Hi Guys, I have a custom view which is set in an NSMenuItem. This view contains 9 rectangles which I would like to track for mouse-over event. I use the the very same method for calculating the size of the rects for drawing and the for defining the tracking rects. What I experience is that events are fired as if the tracking rects are shifted about 4 pixels upwards. Any ideas? Mudi Can you send me a sample project that reproduces this? I'm not aware of any outstanding bugs here. Thanks, -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 [EMAIL PROTECTED]
Re: Always allowing drags from WebView inside a global NSPanel
Just wanted to follow up on this so the list archive has a solution in case anyone searches for anything similar in the future. The solution is courtesy of Darin Adler over on webkitsdk-dev. The solution is to override -[NSWindow sendEvent:] and if the window is not main send the NSLeftMouseDown event twice. The first time the window will become main (and possibly key) and the second will start the drag: -(void)sendEvent:(NSEvent*)event { if (NSLeftMouseDown == [event type] ![self isMainWindow]) [_webView mouse:[_webView convertPoint:[event locationInWindow] fromView:nil] inRect:[_webView visibleRect]]) { [super sendEvent:event]; } [super sendEvent:event]; } The side effect of this is that the NSPanel is now at least the main window, which brings me to my next question. This application is an 'agent' where LSUIElement is set to YES in Info.plist. However, I don't want the agent application to come to the front as this stops events being directed at the last current application. In practice this is OK for some events (mouse down for example) as they change the current application. However, it is confusing in that if you, for example, use cmd+Q then the NSPanel application is quit rather than the one that was in the front. How do I make the agent application I am working on forward on events to the last current application? Nick On Sep 23, 2008, at 3:36 pm, Nick Beadman wrote: Ben, On Sep 23, 2008, at 8:19 am, Benjamin Stiglitz wrote: The problem I am having is that to drag out of the WebView the panel has to be main (i.e. the close/minimize/zoom buttons are filled in). However, if you hold down the command key, the drag out of that window works fine. Where do I start looking to make this work without having to hold down the command key? Have you looked at -[NSView acceptsFirstMouse:]? Thanks for the heads up. This does look like what I need, however, it requires me to override the NSView's that make up WebView. Simply sub-classing WebView and returning YES from acceptsFirstMouse: doesn't work. Looking back through the stack trace from the WebUIDelegate methods it appears that the actual class I am trying to change the implementation of acceptsFirstMouse: is the private WebHTMLView. It is not clear to me where to go from here. poseAs: is deprecated and even then I am dealing with a private class. I am going to try and see if I can get either -[NSApplication sendEvent:] or - [NSWindow sendEvent:] to temporarily bring the window to the front before sending on the event. Any other ideas are welcomed, Nick -- Nick Beadman [EMAIL PROTECTED] (sent from my mailing list account, [EMAIL PROTECTED]) ___ 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 [EMAIL PROTECTED]
Changing slide back destination during drag
I have a view that allows users to drag copies of the items it contains. I'd like to add autoscrolling to the view, which will move the drag's source item. However, I can find no way to change the drag properties so that upon failure the image will slide back to where the item *is* rather than where it *was* before the view autoscrolled. I did find the NSDraggingInfo protocol's slideDraggedImageTo: which I suppose I could have called in my draggedImage:endedAt:operation: dragging source method. But this method is a strange one! The Leopard release notes state the following: -[NSDraggingInfo slideDraggedImageTo:] is now implemented to behave as documented. This change is enabled only for applications built on Leopard or later to avoid changing behavior of older binaries in ways that may be incorrect. So it's working as documented which would be great, but the documentation says it's deprecated (as of Leopard!) with no alternative method! Was -slideDraggedImageTo: really deprecated in the exact release it was also fixed? Or are the release notes just making a little joke (it now behaves as...deprecated)? (And even if it weren't deprecated, would it have enabled me to do what I want?) thanks, -natevw ___ 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 [EMAIL PROTECTED]
Re: NSNotificationCenter
On 27 Sep 2008, at 3:28 am, John Love wrote: In almost all cases, whenever you call the -postNotificationName: method of NSNotificationCenter, the object you pass is 'self'. If it's any other, chances are you've done something weird. So, short answer: your design is a bit whiffy. ;) I love that word whiffy .. so bloody English, so Rex Harrison. Well, I am English, FWIW I moved all -postNotificationName:object: to the receiver and so that's done; not only that, it makes sense. I am the observer, so it's the receiver that is responsible for posting or sending changes to the defaultCenter. First off, let's be clear about terms. I used the terms 'receiver' and 'transmitter' as an analogy for 'observer' and 'observed' respectively. Of course the term 'receiver' also is used frequently when talking about Objective-C to mean 'the object that receives a message' - in other words the instance of a class implementing a particular method. I wasn't using it in that sense so perhaps my choice of terms was misleading. So let's stick to 'observer' (the one responding to the notification) and the 'sender' (the object I want to know about). I said originally: Shouldn't my call to -addObserver automatically monitor StatusChanged rather than my having to -postNotificationName?? It does, but only when the receiver posts. Having said that, let me restate it, perhaps a little more accurately: I would like to some how bind the observer to the receiver so that every time the receiver changes a parameter, it automatically posts that a change has occurred, without having to explicitly post. So now I'm confused about how you're using the term 'receiver'. Do you mean it in the Objective-C sense or as receiver of a notification? You need to ensure that the posting of the notifications is done solely by the sender. Here's how notifications work, in a nutshell: Object A (the sender) changes state. It posts a notification to say so. By some mechanism, Object B (the observer) receives that notification and acts upon it. Maybe another object, C, wants to find out about that same state change, so it can also register itself as an observer of A. When A changes state, both B and C get the notification, etc. By some mechanism is the role of NSNotificationCenter. It just acts as a channel through which these notifications get passed around - otherwise object A would have to know about B and C and every other Tom, Dick or Harry that wanted the info. Instead, using NSNotificationCenter, it only has to know about that, and there is but one global instance, so there is a minimum of coupling between objects. Now, in your case, you were forcing object B to ask object A to tell it about the status change. This is somewhat crazy on a number of levels. First off, if Object B already has a reference to Object A, it can just ask it directly for its status - it doesn't need to say hey, transmit your state to me using a notification please! That's just adding a layer of message wrapping that just isn't needed. But worse, it's polling. Object B is polling Object A for a status change. Polling is bad, so don't do it. The very point of notifications is to eliminate polling. What I said before about passing 'self' is a vital clue. If you're not passing 'self' to -postNotificationName:, you're doing it wrong. Object A is fully and exclusively responsible for posting notifications when it deems that something notifiably important has occurred. Then B, C, Tom, Dick, etc all get the notification and do with it what they will. At no point should B or anyone else be telling A to send a notification. Doing so is wrong, plain and simple. I believe that KVO stands for key-value-order .. so obviously I've got a lot of digging to do, starting with Chapter #1, where ever that is. KVO stands for Key-Value Observation. Personally my advice would be to get ordinary common-or-garden notifications straight before diving into KVO. Ordinary notifications are very simple, straightforward and have no hidden magic. As far as I can tell they will serve your needs for the situation so far described, so I think you're on the right track. While KVO may also fit the bill, it's far, far trickier to get right, and is very unforgiving of not using it exactly properly. I didn't touch KVO until I'd been bashing away with Cocoa for about four years, and even then it took me several false starts before it started working for me instead of the other way around. Unlike ordinary notifications, at first a lot of what KVO does does indeed seem like magic - which in turn implies that you really have to know what you're doing because debugging magic is very hard indeed. KVO builds on KVC, so learn that first. Bindings builds on KVO. Bindings is not for beginners - you really need to have at least the theoretical side of KVC/KVO down pat
Re: [NSCFNumber intValue]: unrecognized selector
On Sep 26, 2008, at 4:36 PM, Steve Rossi wrote: Yes, that is correct. A separate thread is spawned which updates the model - consequently driving UI updates based on KVO notifications. It is the only thread that is updating the model - the main thread does very little except respond to fairly minimal UI events. It works very reliably it seems ... except on these occassions when the OpenPanel is opened from the main thread. That might appear to be the case on your machine, on this version of your application, and on this version of Mac OS X - But as soon as you change any of these variables, it might well start to fall apart. I can think through whether I really need that separate thread. But is there a way to make the model updates from the 2nd thread safe? If you're doing blocking work, having it on a separate thread is probably a good thing - But you need to forward your UI updates to the main thread. That's typically easy to do using performSelectorOnMainThread: j o a r ___ 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 [EMAIL PROTECTED]
NSURLConnection issues
I'm doing an async NSURLConnection and am having issues. It's an http connection, and at first it seems to work. The server sends an authentication challenge (as it should), I respond with credentials, the servers seems to accept the credentials. Then the server responds with an HTTP header like this: 2008-09-26 17:43:20.681 TestApp[27403:10b] 200 - no error 2008-09-26 17:43:20.682 TestApp[27403:10b] { Date = 26 Sep 2008 17:43:20 -0800; Max-Age = 0; } There's no content length, and I never get data from the server. Other programs interact with this same server just fine, so I don't think it's the server end. Also, if I set a breakpoint on the line where I set the credentials, pause the program there, and then resume it, it works just fine. Code is pasted below... -(void)awakeFromNib { NSString *requestText = [NSString stringWithContentsOfFile:@/ Untitled.txt]; NSDictionary *headerFieldsDict = [NSDictionary dictionaryWithObjectsAndKeys:@SomeClient,@User-Agent, @text/xml; charset=utf-8, @Content-Type, @aSoapAction,@SOAPAction, @aHost,@Host, [NSString stringWithFormat:@%d, [[requestText dataUsingEncoding:NSUTF8StringEncoding] length]],@Content-Length, nil]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@https://staging.common.virtualearth.net/find-30/common.asmx ]]; [request setHTTPBody:[requestText dataUsingEncoding:NSUTF8StringEncoding]]; [request setAllHTTPHeaderFields:headerFieldsDict]; [request setHTTPMethod:@POST]; [request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; NSLog([[request allHTTPHeaderFields] description]); NSLog([NSString stringWithUTF8String:[[request HTTPBody] bytes]]); NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; [connection start]; } - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { //pause here using gdb and the program works NSLog(@Wanted authentication...); NSURLCredential *credential = [NSURLCredential credentialWithUser:@user password:@pass persistence:NSURLCredentialPersistenceForSession]; NSLog([[challenge sender] description]); [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; } - (void)connection:(NSURLConnection *)connection didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { NSLog(@authentication canceled..); } - (void)connection:(NSURLConnection *)connection didReceiveData: (NSData *)data { NSLog(@Got data...); NSLog([NSString stringWithUTF8String:(const char *)[data bytes]]); } - (void)connection:(NSURLConnection *)connection didReceiveResponse: (NSHTTPURLResponse *)response { NSLog(@Got Response..); NSLog(@Expected return length %i, [response expectedContentLength]); NSLog(@%d - %@, [response statusCode], [NSHTTPURLResponse localizedStringForStatusCode:[response statusCode]]); NSLog([[response allHeaderFields] description]); } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@Done); } - (void)connection:(NSURLConnection *)connection didFailWithError: (NSError *)error { NSLog(@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 [EMAIL PROTECTED]
Re: sending email with attachement from cocoa
Alexander Cohen wrote: Is there a way to use a url request to open mail with all its fields completed but most importantly, contain an image attachement? Nope. If you want to send an email in the background, you'll need to look into a third-party framework option: http://www.collaboration-world.com/pantomime http://www.theronge.com/mailcore http://www.mulle-kybernetik.com/software/EDFrameworks If you're talking specifically about creating an outgoing message in Mail.app, you'll need to control it via its Apple events ('AppleScript') interface. It's somewhat buggy (chronically so), but can usually be coaxed into doing roughly what you want. I've got an sample project (SendEmail) in appscript's svn repository that shows how to do this using ObjC and appscript: svn checkout http://appscript.svn.sourceforge.net/svnroot/appscript/objc-appscript/trunk objc-appscript I believe there's a sample project somewhere on Apple's site that shows how to do the same sort of thing using Leopard's Scripting Bridge (but I'll not link to that here as I don't have a very high opinion of Scripting Bridge:). HTH has -- Control AppleScriptable applications from Python, Ruby and ObjC: http://appscript.sourceforge.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 [EMAIL PROTECTED]
Re: sending email with attachement from cocoa
On Sat, Sep 27, 2008 at 4:11 AM, has [EMAIL PROTECTED] wrote: Alexander Cohen wrote: Is there a way to use a url request to open mail with all its fields completed but most importantly, contain an image attachement? Nope. If you want to send an email in the background, you'll need to look into a third-party framework option: http://www.collaboration-world.com/pantomime http://www.theronge.com/mailcore http://www.mulle-kybernetik.com/software/EDFrameworks If you're talking specifically about creating an outgoing message in Mail.app, you'll need to control it via its Apple events ('AppleScript') interface. It's somewhat buggy (chronically so), but can usually be coaxed into doing roughly what you want. I've got an sample project (SendEmail) in appscript's svn repository that shows how to do this using ObjC and appscript: svn checkout http://appscript.svn.sourceforge.net/svnroot/appscript/objc-appscript/trunk objc-appscript I believe there's a sample project somewhere on Apple's site that shows how to do the same sort of thing using Leopard's Scripting Bridge (but I'll not link to that here as I don't have a very high opinion of Scripting Bridge:). There's also our CSMail framework which, unlike the others above, talks to the locally installed e-mail client rather than using SMTP directly. It supports Mail, Entourage and Eudora at the moment. See: http://www.coriolis-systems.com/opensource -- 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 [EMAIL PROTECTED]
Re: [NSCFNumber intValue]: unrecognized selector
On Sep 26, 2008, at 11:22 AM, j o a r wrote: On Sep 25, 2008, at 6:22 AM, Steve Rossi wrote: I've deduced that he crash seems to be something timing related which occurs only at application startup, and only under certain conditions (i.e. reproduce occassionlly by opening an NSOpenPanel modal dialog before the application is fully up and running). When I say the application is fully up and running, I mean a secondary thread has retrieved data from a network source and populated a model class. This secondary thread cyclically updates the data about 8x per second by means of a timer in the secondary thread's run loop. I use Cocoa bindings to display the data in the UI. I'm sure the problem is happening in the bindings, but I'm having trouble finding where. In the general case, and with few exceptions, you can't call your UI on non-main threads. This means that you can't drive UI updates based on KVO notifications from non-main threads. Could this be your problem? j o a r Yes, that is correct. A separate thread is spawned which updates the model - consequently driving UI updates based on KVO notifications. It is the only thread that is updating the model - the main thread does very little except respond to fairly minimal UI events. It works very reliably it seems ... except on these occassions when the OpenPanel is opened from the main thread. I can think through whether I really need that separate thread. But is there a way to make the model updates from the 2nd thread safe? ___ 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 [EMAIL PROTECTED]
Re: Using aggregate functions in a Core Data Fetch Request
What about taking your objects and sorting them by value, and popping the last object? NSFetchPredicate *fr = /* lets say this is setEntity to your entity */; NSManagedObjectContext *moc = /* your moc here */; [fr setSortDescriptor: [[[NSSortDescriptor alloc] initWithKey:@value ascending:YES] autorelease]]; NSArray *result = [moc executeFetchRequest:fr error:nil]; id maxObj = [result lastObject]; If you're using the id as a sort of UID, however, I would just use CFUUIDCreate() to make an ID that's guaranteed to be unique without quizzing the data store. On Sep 26, 2008, at 12:25 PM, Fred McCann wrote: I'm attempting to find an object that has a maximum value in the data store. In sql, the query would be something like this: select * from foo where value = select max(value) from foo. Actually, I would be thrilled if I could just get select max(value) from foo. I've read through the Core Data and Predicates pdfs, and there is a mention of a max function in the BNF Definition of Cocoa Predicates of the Predicates document, but I've had no luck. My current attempt is to create a fetch request in the XCode Data Modeler using the predicate: id == max:( id ) When I try to execute this, I get this error: Unable to generate SQL for predicate (id == max:( $FETCHED_PROPERTY.id )) (problem on RHS) I'm currently using Sqlite as the backing store. Does anyone have any suggestions on how to do this? Is this even possible? What I'm trying to accomplish is to maintain ids across multiple persistent stores that can weakly linked as fetched properties. - Fred McCann [EMAIL PROTECTED] ___ 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/jamiehardt %40gmail.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: problems in runModal in NSOpenPanel used with defaults
Thanks Corbin, I have used your tips in the updated code. Besides, my aim is to save the filename selected through the panel to a pList file timely whenever it is changed, so I am using synchronization of defaults. I checked and found that there is no resetStandardUserDefaults used anywhere in the entire project. I tried implementing dictionary insted of defaults and updating the pList contents accordingly. But to my surprise, in either cases(dictionary/defaults), whenever I click browse and click cancel/open the junk values are appended automatically in the pList file!!! For the time being I am deleting and recreating the file, but it doesn't seem a good alternative!!! How can a 'Panel runModal' add such junk in the pList!!! Sparta... On Fri, Sep 26, 2008 at 10:48 PM, Corbin Dunn [EMAIL PROTECTED] wrote: Howdy spartan, Oh! A few little tips: On Sep 26, 2008, at 3:11 AM, spartan g wrote: Hi, I am writing an utility which needs to open a panel to browse files and select one. - (IBAction)browseClicked:(id)sender { NSOpenPanel *panel = [NSOpenPanel openPanel]; if ([panel runModal]) { NSArray *filenames = [panel filenames]; NSString *filename = [filenames objectAtIndex:0]; Always check the array length first, or just use [panel filename]; if (filename){ printf(\n browseClicked: filename = %s \n, [filename cString]); Just a side note: most cocoa people move to NSLog, but printf still works. Try: NSLog(@%@, filename); -- much easier! if ([appToOpenText stringValue] != NULL ){ nil is preferred to NULL. [appToOpenText setStringValue: filename]; } else printf(\n browseClicked: appToOpenText has NULL value \n); } else printf (\n *** browseClicked: Filename is NULL *** \n); } } The filename chosen is assigned to the textfield. I have used defaults to synchronize this filename and storing it in a pList file. [_defaults setObject: [appToOpenText stringValue] forKey: @AppToOpen ]; It seems strange to use the user defaults as your model to store objects, but i'm sure there is a reason you do this. [_defaults synchronize]; You probably don't want to hold onto the userdefaults instance as an ivar, and instead always query it with [NSUserDefaults standardUserDefaults]. It may be possible that something is calling resetStandardUserDefaults, and blowing away the old instance. 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 [EMAIL PROTECTED]