Re: Error with malloc and NSFileWrapper
On Dec 17, 2008, at 7:22 PM, Guillaume Campagna wrote: I'm using a NSDirectoryEnumerator to add all the content of a folder to some array... I'm filtering these files (I don't want certains types of files). One of these file types is symbolic link (alias). So I'm using NSFileWrapper to check that with -(BOOL) isRegularFile. Don't do that. That's not what NSFileWrapper is for. Note especially that NSFileWrapper is going to enumerate all the files for any directory you specify for the path, meaning you'll enumerate every directory multiple times, once for each parent it has. Use this: if ([[[e fileAttributes] fileType] isEqualToString:NSFileTypeRegular]) // ... where 'e' is the directory enumerator you're using. In other words, the enumerator already provides a convenient way to obtain the file attributes you're looking for. Cheers, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: UNIX signals
On Dec 18, 2008, at 12:59 PM, Michael Ash wrote: Good luck finding *any* documentation about the mach functions. (Seriously. If you know of good Apple-provided ones, I'd like to know!) Normally I'd be wary, but in this case not having documentation is simply par for the course. As you probably know, Apple considers the Mach functions as private SPI (System Programming Interfaces). Still, there's some documentation for them. It's out of date in substantial respects, though. It's among the Darwin source files: http://www.opensource.apple.com/darwinsource/10.5.6/xnu-1228.9.59/osfmk/man/ (Note that the nature of web browsers is that they'll show you the contents of index.html at that location, rather than a listing of all the files within that directory. It may be easiest to download the tarball and browse the directory that way.) Cheers, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Fwd: NSData downloaded over socket is bigger than it should be...
I think that this there is still not enough example code here to help. I use AsyncSocket extensively and any trouble I have had with data transfer has been my fault entirely. -(void)onSocket:(AsyncSocket *)sock didReadData:(NSData*)data withTag:(long)tag Having said that I always use the AsyncSocket method - (void)readDataToLength:(CFIndex)length withTimeout: (NSTimeInterval)timeout tag:(long)tag; Maybe not possible in your case if you don't know the transfer size to begin with. Maybe try constructing some test data of a known size that causes failure. Then swap your call to (void)onSocket:(AsyncSocket *)sock didReadData:(NSData*)data withTag: (long)tag for a single call to - (void)readDataToLength:(CFIndex)length withTimeout: (NSTimeInterval)timeout tag:(long)tag; using your known data length. Should help to sort out were the data is getting mishandled. It's a bit hard to track because the setup,as I said, works with multiple simultaneous connections etc, but it's really straight forward: ONE socket downloads ONE segment and save it to disk... the decoder deals with putting all the segments together once all the segments of a file have been downloaded... but most segments have extra bytes in them... Does the problem only arise when multiple connections are active, or can it be triggered in a single isolated transfer? And to make it workse, sometimes (usually when I grab stuff like images or smaller stuff like that which consist of only 1 segment) then they end up just fine... the extra bytes are only present with bigger attachment (of 1mb+) and especially with multiparts attachments... This is not worse, its better. Implies that the problem may arise from conjoining the segments. Jonathan Mitchell Central Conscious Unit http://www.mugginsoft.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: -[NSURLConnection cancel] doesn't release its delegate?
On Thu, Dec 18, 2008 at 6:43 PM, Stephen J. Butler stephen.but...@gmail.com wrote: Actually, this works for me on 10.5.6, with XCode 3.1.1. The assert doesn't trigger. ... Or it could be a bug that was fixed in the latest release.Try putting a run loop in your main function instead. I'd try it, but like I said, I don't think I'm seeing the failure. Mmm, you're right - the bug exists on 10.5.5 (and other OS X platforms...), but seems to be fixed in 10.5.6. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
SocketPort allocating
I had Distributed object which can used by any client, i am establishing connection using a port , every thing works fine.My object is vended and the client can use the vended object . But i am getting problem when i restart my server which supplies vended object. When i am restarting sometimes my socket is not get allocated , and this is beecause the socket is using by any of the client, how can i resolve this situation . NSSocketPort *serverPort = [[[NSSocketPort alloc] initWithTCPPort: 3002] autorelease]; aConnection = [[NSConnection alloc] initWithReceivePort:serverPort sendPort:nil]; NSRunLoop *runloop = [NSRunLoop currentRunLoop]; [aConnection setRootObject:[ServerObject sharedServerObject]]; Regards kiran ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Enabling add button
Thanks a lot Mark, This works great. The only change I made is to test with isEqualTo for the table view's specific instance to prevent adding rows when the master table is the first responder. And no flickers when presenting a sheet :-) Thanks again, Andre Masse On Dec 19, 2008, at 06:29, Mark wrote: I did something like this once. I'm not sure if this is a good way to tackle the problem or not but here's what you need: - A BOOL ivar exposed as a property on one of your controllers: BOOL isTableViewSelected; @property(assign) BOOL isTableViewSelected; @synthesize isTableViewSelected; - Next, set up an observer of NSWindowDidUpdateNotification in - awakeFromNib or somewhere else so we can watch for any changes in the window (like first responder changing): [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkFirstResponderStatusNotification:) name:NSWindowDidUpdateNotification object:[aView window]]; // -- Get to the main window somehow - In the selector for the notification check the class of the first responder and then set the isTableViewSelected ivar accordingly. By using the synthesized setter it broadcasts change notifications so you can bind the 'Enabled' binding of the button to yourController.isTableViewSelected and it should then update its status correctly as you move around your UI. - (void)checkFirstResponderStatusNotification:(NSNotification *)note { NSWindow *mainWindow = [self.aView window]; // -- Get to the main window somehow self.isTableViewSelected = ([[mainWindow firstResponder] isKindOfClass:[NSTableView class]]); } I think this should work, you'll probably have to fiddle about with some things (I originally used this to check the class of one of my own classes, not a table view). I think there was some weird problems with flickering (rapid on/off changes?) when a sheet was present on the window which I never got round to solving, ymmv. (Also [[NSNotificationCenter defaultCenter] removeObserver:self]; in -dealloc or elsewhere) On 18 Dec 2008, at 23:28, Andre Masse wrote: On Dec 18, 2008, at 15:43, I. Savant wrote: The issue Andre mentioned is that the app is mostly keyboard-driven (and the key combo fires the button, which he fears can be triggered inadvertently). This means it doesn't matter where the button is - the key combo can still trigger the action without calling enough attention to the resulting insert. Exactly. You're way better than me explaining my own problems :-) I used to talk/write English much more 5-6 years ago (even co- translated a book from French to English). Now, I only use English in this list and it shows :-) Thanks, Andre Masse ___ 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/blue.buconero%40virgin.net This email sent to blue.bucon...@virgin.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: does this crash make sense to anyone?
Thank you. I have read up on NSZombie et al and found a non-retained object that may have been the culprit, although it's too early to say definitely. I'll keep investigating... Cheers On Thu, Dec 18, 2008 at 8:49 PM, Shawn Erickson shaw...@gmail.com wrote: On Thu, Dec 18, 2008 at 11:45 AM, Shawn Erickson shaw...@gmail.com wrote: On Thu, Dec 18, 2008 at 11:33 AM, slasktrattena...@gmail.com slasktrattena...@gmail.com wrote: Hi, my app keeps annoying me by crashing at launch every now and then. What's weird about the backtrace is that it tells me I have called a CLASS method named setFrame:. The class varies: in this case it says NSClipView, sometimes is says NSAttributedString, or NSObject, or whatever. Of course, I don't make any such calls explicitly, and most of the time the app launches just fine. Any idea what the problem could be, or how to locate it with gdb? I never learned using the debugger properly. This is indicative of not correctly retaining an object (likely an object given to you that you then stick into an instance var without taking ownership of it) . As a result the object is deallocated out from under you (likely as a result of the currently auto release pool being drained) and then that slot in memory is randomly replaced with a different object instance likely of a totally unrelated class. You can use NSZombie to help isolate... http://developer.apple.com/technotes/tn2004/tn2124.html I should note it could also be because you are releasing an object that you shouldn't be releasing. Normally an over release would fail in a different way (crash in a future release message) but it is possible to get what you are seeing because of an over release in addition to an under release situation. If this is a GC using application then the issue will be different. -Shawn ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
download security hanging app - It's a more general Problem + Solution
It seems to be a more general bug with runModalForWindow: If anything grabs the focus while the app is starting (i.e. something that would require you click on the dock icon to get the app back - which the warning does) the modal window never becomes visible. I can see the same thing by starting the app from the debugger and clicking on a different app before the debugged app is completely up. The work around was to move the runModalForWindow: to - (void)applicationDidBecomeActive:(NSNotification *)aNotification with a static guard variable so that the reg window is launched only the first time the app becomes active in a session. ( applicationDidBecomeActive: isn't called until you click to get the app back.) ...Bob ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSNoSelectionMarker example?
Namaste! Anyone have an example of using NSNoSelectionMarker in a value transformer? If so, would you mind sharing? I've looked at what documentation I can locate and am not able to retrieve an appropriate example. The difficulty I'm having is having value evaluate properly against NSNoSelectionMarker. Thanks in advance! Peace, Love, and Light, /s/ Jon C. Munson II ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: User Default Bindings
Gerriet Denkman wrote: A related question: In Tiger I often used a Model Key Path containing blanks. Now IB (Version 3.1.1 (672)) does no longer allows me to enter this. Where is the definition of a valid key path to be found? Spaces obviously cannot occur in Obj-C method keypaths, but they are perfectly valid in preference / dictionary keys (Apple uses them too). So the definition of 'valid keypath' depends on the context where it's used. The fact that IB doesn't allow binding to keypaths containing spaces is an unfortunate bug in IB 3.x I filed a bug some months ago: rdar://problem/6119335 Spaces in NSUserDefaults key bindings not allowed in Interface Builder 3.1 patrick -- Patrick Machielse Hieper Software http://www.hieper.nl i...@hieper.nl ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Optimizing NSRectFill
I'm developing a custom view and noticed that drawRect is becoming increasingly slow. The Shark has pointed out that the bottleneck is the NSRectFill function (that calls CGContextFillRect under the hood) that I use to draw the background of the view. I am disappointed that such a basic operation could ever impair performance, but it does. It looks like the bigger is the rectangle, the slower is performance. I have read the list regarding this issue, but I haven't found any solution. NSRectFillList, CGContextFillRect do not give any performance gain. My question is - is there a way to bypass the advanced path-related stuff that causes the slow-down, and just get down to some kind of fast drawing? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Optimizing NSRectFill
On Dec 19, 2008, at 4:37 PM, Oleg Krupnov wrote: I'm developing a custom view and noticed that drawRect is becoming increasingly slow. The Shark has pointed out that the bottleneck is the NSRectFill function (that calls CGContextFillRect under the hood) that I use to draw the background of the view. I am disappointed that such a basic operation could ever impair performance, but it does. It looks like the bigger is the rectangle, the slower is performance. I have read the list regarding this issue, but I haven't found any solution. NSRectFillList, CGContextFillRect do not give any performance gain. My question is - is there a way to bypass the advanced path-related stuff that causes the slow-down, and just get down to some kind of fast drawing? There are different ways to optimize drawRect: drawings. Most of them involves only refreshing the parts of the view that are really needed to be refreshed. You have different APIs and pieces of information that can help you with this task. The first one being the NSRect used as the parameter for drawRect:. It describes the bounding box of the refresh area. If your issue is with the background of the view and your background pattern is just a color, use this NSRect for NSRectFill. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSData downloaded over socket is bigger than it should be...
Well after doing more tests... It happens even if I only have 1 active connection and it also happens even if only download 1 part of the multiparts file (i.e. the part is still slightly bigger than it should be) so basically the files that were ending up ok with multiple connections are still fine, the files that were ending up bigger than they should... are still bigger What I *don't* understand is how the data can be bigger I would understand if some bytes were lost... but added?? I just don't see why it's happening... I'm tempted to re-write my ConnectionController with NetSocket to see if I get the same result... On 19-Dec-08, at 4:55 AM, jonat...@mugginsoft.com wrote: I think that this there is still not enough example code here to help. I use AsyncSocket extensively and any trouble I have had with data transfer has been my fault entirely. -(void)onSocket:(AsyncSocket *)sock didReadData:(NSData*)data withTag:(long)tag Having said that I always use the AsyncSocket method - (void)readDataToLength:(CFIndex)length withTimeout: (NSTimeInterval)timeout tag:(long)tag; Maybe not possible in your case if you don't know the transfer size to begin with. Maybe try constructing some test data of a known size that causes failure. Then swap your call to (void)onSocket:(AsyncSocket *)sock didReadData:(NSData*)data withTag: (long)tag for a single call to - (void)readDataToLength:(CFIndex)length withTimeout: (NSTimeInterval)timeout tag:(long)tag; using your known data length. Should help to sort out were the data is getting mishandled. It's a bit hard to track because the setup,as I said, works with multiple simultaneous connections etc, but it's really straight forward: ONE socket downloads ONE segment and save it to disk... the decoder deals with putting all the segments together once all the segments of a file have been downloaded... but most segments have extra bytes in them... Does the problem only arise when multiple connections are active, or can it be triggered in a single isolated transfer? And to make it workse, sometimes (usually when I grab stuff like images or smaller stuff like that which consist of only 1 segment) then they end up just fine... the extra bytes are only present with bigger attachment (of 1mb+) and especially with multiparts attachments... This is not worse, its better. Implies that the problem may arise from conjoining the segments. Jonathan Mitchell Central Conscious Unit http://www.mugginsoft.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/silvertab%40videotron.ca This email sent to silver...@videotron.ca Jean-Nicolas Jolivet silver...@videotron.ca http://www.silverscripting.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Listening for changes
Let's say I have a class (called it Client) that has 25 fields and need to be notified when any of these is modified. Do I have to do - observeValueForKeyPath for each of the 25 fields? Thanks, Andre Masse ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSData downloaded over socket is bigger than it should be...
On Fri, Dec 19, 2008 at 11:43 AM, Jean-Nicolas Jolivet silver...@videotron.ca wrote: Well after doing more tests... It happens even if I only have 1 active connection and it also happens even if only download 1 part of the multiparts file (i.e. the part is still slightly bigger than it should be) so basically the files that were ending up ok with multiple connections are still fine, the files that were ending up bigger than they should... are still bigger What I *don't* understand is how the data can be bigger I would understand if some bytes were lost... but added?? I just don't see why it's happening... I'm tempted to re-write my ConnectionController with NetSocket to see if I get the same result... I'll ask again: where do these extra bytes appear, and what do they contain? That will give you a big clue. If that's not enough, instrument your code. Log the data being downloaded at every step of the way. At some point it will change from being good to being bad. Then you have your answer. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSData downloaded over socket is bigger than it should be...
I would love to give you an answer! The problem is that every newsreader out there that download binary files automatically decode and join the parts... I can't download just one part to test it against the part that my app downloaded!... I'm still trying to find another app that might be able to download parts of multiparts email attachment WITHOUT joining the parts once its done but ... well it's just not that easy to find unfortunately! On 19-Dec-08, at 12:07 PM, Michael Ash wrote: On Fri, Dec 19, 2008 at 11:43 AM, Jean-Nicolas Jolivet silver...@videotron.ca wrote: Well after doing more tests... It happens even if I only have 1 active connection and it also happens even if only download 1 part of the multiparts file (i.e. the part is still slightly bigger than it should be) so basically the files that were ending up ok with multiple connections are still fine, the files that were ending up bigger than they should... are still bigger What I *don't* understand is how the data can be bigger I would understand if some bytes were lost... but added?? I just don't see why it's happening... I'm tempted to re-write my ConnectionController with NetSocket to see if I get the same result... I'll ask again: where do these extra bytes appear, and what do they contain? That will give you a big clue. If that's not enough, instrument your code. Log the data being downloaded at every step of the way. At some point it will change from being good to being bad. Then you have your answer. 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/silvertab%40videotron.ca This email sent to silver...@videotron.ca Jean-Nicolas Jolivet silver...@videotron.ca http://www.silverscripting.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Is NSKeyedArchiver portable / reliable?
I need to include a set of data with my application. It is an Array of about 1500 objects. Since this may also be used as an iphone app, I need this to be as fast and efficient as possible. I want to use NSKeyedArchiver to serialize the data to a file, and then include that file in the application. The file will then be loaded at runtime and the Array de-serialized. However, I am not sure how reliable this is. 1. Would this work across different machines? 2. Is there a risk that apple would change the serialization format, thus breaking my app in the future? i.e. can / should I expect the serialization implementation to remain the same? 3. Anyone know if this would work on the iPhone? thanks for any input... mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Listening for changes
On Dec 19, 2008, at 11:06 AM, Andre Masse wrote: Let's say I have a class (called it Client) that has 25 fields and need to be notified when any of these is modified. Do I have to do - observeValueForKeyPath for each of the 25 fields? You can add one fake property, use +keyPathsForValuesAffectingKey to tell KVO that all of your other keys affect the value of this one property, and then observe that one key. On Tiger, you'd have to use +setKeys:triggerChangeNotificationsForDependentKey: to tell KVO about the dependencies. Cheers, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Listening for changes
Thanks for the great trick! Andre Masse On Dec 19, 2008, at 12:35, Ken Thomases wrote: On Dec 19, 2008, at 11:06 AM, Andre Masse wrote: Let's say I have a class (called it Client) that has 25 fields and need to be notified when any of these is modified. Do I have to do - observeValueForKeyPath for each of the 25 fields? You can add one fake property, use +keyPathsForValuesAffectingKey to tell KVO that all of your other keys affect the value of this one property, and then observe that one key. On Tiger, you'd have to use +setKeys:triggerChangeNotificationsForDependentKey: to tell KVO about the dependencies. Cheers, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [Q] How to let the pasteboard know a file type?
Hello. I found out that NSCreateFilenamePboardType() would help. So, I tried it like : My code example is : In awakeFromNib NSString http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSString.html *quicktimeFileNamesPboardType = NSCreateFilenamePboardType(@mov); [myNSTableView registerForDraggedTypes:[NSArray http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSArray.html arryWithObject:quickTimeFileNamesPboardType]]; In -tableView:writeRowsWithIndexes:toPasteboard: NSString http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSString.html *quicktimeFileNamesPboardType = NSCreateFilenamePboardType(@mov); anIndex = [selectedRowsIndexSet firstIndex]; while( anIndex != NSNotFound ) { fileName = [NSString http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSString.html stringWithFormat:@%@/%...@.mov, configPath, [[dataArray objectAtIndex:anIndex] name]]; [fileNamesArray addObject:fileName]; // Next index anIndex = [selectedRowIndexSet indexGreaterThanIndex:anIndex]; } [pboard declareTypes:[NSArray http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSArray.html arrayWithObjects:quicktimeFilenamesPboardType, nil] owner:nil]; isSuccessful = [pboard setPropertyList:fileNamesArray forType:quicktimeFilenamesPboardType]; ... When I check what information is exported from my program with the Drag Peeker X, it shows : Item Reference: 19884c10 Item Bounds (tlbr): { 86, 1, 104, 191 } Number of flavors: 0 Strangely, it doesn't have any flavor of data. Is there anything wrong how I use the NSCreateNSFilenamePboardType? How to use it properly? Thank you in advance. P.S. By the way, is it normal to put 'furl' and 'hfs' flavor when NSFilenamesPboardType is used? Because an array of file names are added to the pasteboard, I thought that only file name strings were added. But it turned out no-so-true. JongAm Park wrote: Hi, Thanks to a utility program, called DragPeeker X, I found out some clue why the FCP treated dragged file as a file with unknown type. When I dragged the same file from the Finder to the FCP, it shows : Number of Items: 1 1. Item Reference: 19884c10 Item Bounds (tlbr): { 86, 1, 104, 191 } Number of flavors: 2 1.Flavor Type: 'furl' Flavor Flags: 0 Length: 54 Data: 66 69 6C 65 3A 2F 2F 6C 6F 63 61 6C 68 6F 73 74 file://localhost 2F 56 6F 6C 75 6D 65 73 2F 31 37 32 2E 31 36 2E /Volumes/172.16. 32 34 36 2E 31 34 36 2F 4D 4F 56 2F 30 30 30 33 246.146/MOV/0003 59 42 2E 6D 6F 76 YB.mov2.Flavor Type: 'hfs ' Flavor Flags: 300 Length: 80 Data: 4D 6F 6F 56 3F 3F 3F 3F 00 00 FF 98 00 00 00 13 MooV 0A 30 30 30 33 59 42 2E 6D 6F 76 DC 00 00 00 00 .0003YB.mov. FF FF FF FF 00 00 00 00 00 25 F0 A0 A0 31 60 34 .%...1`4 91 F6 C0 A0 BF FF DA 80 84 04 20 42 91 F6 6B 44 .. B..kD 91 F6 C0 A0 00 86 B4 00 17 BB 17 FC BF FF DA C4 But if I drag one from my application to the FCP, it shows : Number of Items: 1 1. Item Reference: c0c0a Item Bounds (tlbr): { 219, 244, 219, 244 } Number of flavors: 2 1.Flavor Type: 'furl' Flavor Flags: 0 Length: 54 Data: 66 69 6C 65 3A 2F 2F 6C 6F 63 61 6C 68 6F 73 74 file://localhost 2F 56 6F 6C 75 6D 65 73 2F 31 37 32 2E 31 36 2E /Volumes/172.16. 32 34 36 2E 31 34 36 2F 4D 4F 56 2F 30 30 30 33 246.146/MOV/0003 59 42 2E 6D 6F 76 YB.mov2.Flavor Type: 'hfs ' Flavor Flags: 0 Length: 80 Data: 00 00 00 00 00 00 00 00 00 00 FF 98 00 00 00 13 0A 30 30 30 33 59 42 2E 6D 6F 76 FC 00 25 DB A0 .0003YB.mov..%.. 00 00 00 06 00 18 80 00 00 00 00 60 00 25 8E B0 ...`.%.. 90 10 7A 44 BF FF DA 70 44 04 20 42 90 10 7D EC ..zD...pD. B..}. 00 00 00 02 BF FF DA 90 00 00 00 20 BF FF DC F4 ... ( I also tried NSURLPboardType and NSFileContentsPboardType. But they didn't make information like above appear. ) The PboardType I used was NSFilenamesPboardType. The major difference between those are in the 2nd flavor type 'hfs'. Their flavor flags are different: one is 300, while the other is 0. What actually matters, I think, is the data of the 2nd flavor. The one using the Finder starts with MooV, which says that the dragged item is a QuickTime movie, while the one from my application doesn't contain
Cocoa Apple Script Problem
I have implemented the required methods to support creating an object in Apple Script, but it does not work as advertised. This does work as expected tell front document make new family at end tell last family set properties to {husband:@I5@} end tell end tell This creates the object but does NOT set the properties tell front document make new family at end with properties {husband:@I5@} end tell The family objects are tied to key-value methods using key = famRecords in my suite and the method getting called by both these make commands is - (void)insertInFamRecords:(id)object where object is the correct FAMRecord type. If set properties to works on an existing object, shouldn't it work when creating a new one? Do have to manuul find a way to override the make command? Curiously this method of form insertInKeyRecords: is not even mentioned in the Key-Value Coding and Cocoa Scripting section of the Cocoa Scripting Guide. I had to find it by an error message in the Console before it was present. --- John Nairn GEDitCOM - Genealogy Software for the Macintosh http://www.geditcom.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Is NSKeyedArchiver portable / reliable?
On Dec 19, 2008, at 9:24 AM, Mike Chambers wrote: 1. Would this work across different machines? If by different machines you mean PPC, Intel, 32-bit, 64-bit, iPhone, iPod, etc. then yes. NSKeyedArchiver is documented as being architecture-independent. There are some subtle differences between architectures in what gets returned when you call @encode for a primitive type, but nothing you can't work around. Also, not all classes available on desktop OS X are available on the iPhone/iPod, but common ones ought to work. 2. Is there a risk that apple would change the serialization format, thus breaking my app in the future? No; that would break pretty much every desktop app if they did that. Nick Zitzmann http://www.chronosnet.com/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSData downloaded over socket is bigger than it should be...
Well after comparing the data that I am receiving with the data that I SHOULD be receiving, it turns out that dots (yes, the dot character (.) ) are added all over the place in the data if I have 10 extra bytes, it means 10 extra dots were added to my data, so for example, a line that SHOULD read: .m;{äMãP#ü1TMëLÆÖ-«½4i¯àÚPëýgêæ¯Ø Instead reads: ..m;{äMãP#ü1TMëLÆÖ-«½4i¯àÚPëýgêæ¯Ø Notice the extra dot at the beginning of the line... it turns out that ALL the extra dots that gets added are at the beginning of lines, when there is already a dot there Now, that data is downloaded straight from the socket and saved to disk, I am not adding/merging nor doing anything with it so I wonder if it's not a bug with AsyncSocket?? but I guess if it were adding dots all over the place people would've notice it already... I'm out of ideas here really! On 19-Dec-08, at 12:20 PM, Jean-Nicolas Jolivet wrote: I would love to give you an answer! The problem is that every newsreader out there that download binary files automatically decode and join the parts... I can't download just one part to test it against the part that my app downloaded!... I'm still trying to find another app that might be able to download parts of multiparts email attachment WITHOUT joining the parts once its done but ... well it's just not that easy to find unfortunately! On 19-Dec-08, at 12:07 PM, Michael Ash wrote: On Fri, Dec 19, 2008 at 11:43 AM, Jean-Nicolas Jolivet silver...@videotron.ca wrote: Well after doing more tests... It happens even if I only have 1 active connection and it also happens even if only download 1 part of the multiparts file (i.e. the part is still slightly bigger than it should be) so basically the files that were ending up ok with multiple connections are still fine, the files that were ending up bigger than they should... are still bigger What I *don't* understand is how the data can be bigger I would understand if some bytes were lost... but added?? I just don't see why it's happening... I'm tempted to re-write my ConnectionController with NetSocket to see if I get the same result... I'll ask again: where do these extra bytes appear, and what do they contain? That will give you a big clue. If that's not enough, instrument your code. Log the data being downloaded at every step of the way. At some point it will change from being good to being bad. Then you have your answer. 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/silvertab%40videotron.ca This email sent to silver...@videotron.ca Jean-Nicolas Jolivet silver...@videotron.ca http://www.silverscripting.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/silvertab%40videotron.ca This email sent to silver...@videotron.ca Jean-Nicolas Jolivet silver...@videotron.ca http://www.silverscripting.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Optimizing NSRectFill
On Dec 19, 2008, at 7:37 AM, Oleg Krupnov wrote: I'm developing a custom view and noticed that drawRect is becoming increasingly slow. The Shark has pointed out that the bottleneck is the NSRectFill function (that calls CGContextFillRect under the hood) that I use to draw the background of the view. I am disappointed that such a basic operation could ever impair performance, but it does. It looks like the bigger is the rectangle, the slower is performance. I have read the list regarding this issue, but I haven't found any solution. NSRectFillList, CGContextFillRect do not give any performance gain. My question is - is there a way to bypass the advanced path-related stuff that causes the slow-down, and just get down to some kind of fast drawing? NSRectFill is really damned fast. Very very fast. In my experience, it was the fastest way to draw points into a view (and then cache the points into bitmap images for subsequent renderings). See: http://svn.red-bean.com/restedit/trunk/source/HopView.py (It is in python, but it is Cocoa and uses the same APIs as you'd use in ObjC). That code is literally rendering 10,000 points -- 10,000 1x1 rects -- at a time in a few milliseconds. From what anyone could tell, it was the fastest way to get individual points to the screen without going to Open GL. That makes me suspect that there is something else going on in your drawing code. That it becomes increasingly slow indicates that you are accumulating and then drawing more and more stuff over time? Are you doing the calculations necessary to not draw the overlapping bits? A little bit of math is always going to be faster than drawing to the screen. b.bum ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSData downloaded over socket is bigger than it should be...
On Dec 19, 2008, at 12:24 PM, Jean-Nicolas Jolivet wrote: Well after comparing the data that I am receiving with the data that I SHOULD be receiving, it turns out that dots (yes, the dot character (.) ) are added all over the place in the data if I have 10 extra bytes, it means 10 extra dots were added to my data, so for example, a line that SHOULD read: .m;{äMã≈P#ü1ˆTMëLÆÖ-«∏4iˇ¯àÚPë‡gêæ¯Ø Instead reads: ..m;{äMã≈P#ü1ˆTMëLÆÖ-«∏4iˇ¯àÚPë‡gêæ¯Ø Notice the extra dot at the beginning of the line... it turns out that ALL the extra dots that gets added are at the beginning of lines, when there is already a dot there Now, that data is downloaded straight from the socket and saved to disk, I am not adding/merging nor doing anything with it so I wonder if it's not a bug with AsyncSocket?? but I guess if it were adding dots all over the place people would've notice it already... I'm out of ideas here really! I could be wrong on this, but assuming you're using NNTP, ISTR it documented to have lines separated by cr+lf? And that the multi-part stuff is based lines separated by those pairs - and if you separate into lines based one only one of them, the extra will get added (erroneously) to the line? Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! Cardographer | the custom playing card designer ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Listening for changes
Hmm.. Thought this would be easy but I'm stuck... Here's what I've done: - added the fake property BOOL needSaving @property(assign, nonatomic) BOOL needSaving; @synthesize needSaving; - implemented keyPathsForValuesAffecting (I'm on Leopard) + (NSSet*)keyPathsForValuesAffectingValueForKey:(NSString*)key { NSSet* set = [super keyPathsForValuesAffectingValueForKey:key]; if ([key isEqualToString:@needSaving]) { set = [set setByAddingObjectsFromSet:[NSSet setWithObjects: @lastName, @firstName, ... nil]]; } return set; } Now, I just can't figure out how I should implement - (BOOL) needSaving! Setting it to NO in -init and implementing it like this obviously doesn't work: - (BOOL) needSaving { return YES; } Thanks, Andre Masse On Dec 19, 2008, at 12:35, Ken Thomases wrote: On Dec 19, 2008, at 11:06 AM, Andre Masse wrote: Let's say I have a class (called it Client) that has 25 fields and need to be notified when any of these is modified. Do I have to do - observeValueForKeyPath for each of the 25 fields? You can add one fake property, use +keyPathsForValuesAffectingKey to tell KVO that all of your other keys affect the value of this one property, and then observe that one key. On Tiger, you'd have to use +setKeys:triggerChangeNotificationsForDependentKey: to tell KVO about the dependencies. Cheers, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSData downloaded over socket is bigger than it should be...
I am indeed using NNTP, but really I'm not even looking at cr+lf etc... Basically I'm sending the following command to retrieve a message: ARTICLE message-id\r\n Then I'm reading all the data up until \r\n.\r\n is found (that is, a new line, a dot, and a new line again) which marks the end of an email and I'm saving that data to the disk mmm, now that I say it like that though a dot on a newline marks the end of a message... and my problem is that I have dot inserted on new lines? can't be a coincidence!... but then again, I'm using AsyncSocket's readToData function... so I don't have much control over that... On 19-Dec-08, at 1:34 PM, glenn andreas wrote: On Dec 19, 2008, at 12:24 PM, Jean-Nicolas Jolivet wrote: Well after comparing the data that I am receiving with the data that I SHOULD be receiving, it turns out that dots (yes, the dot character (.) ) are added all over the place in the data if I have 10 extra bytes, it means 10 extra dots were added to my data, so for example, a line that SHOULD read: .m;{äMã≈P#ü1ˆTMëLÆÖ-«∏4iˇ¯àÚPë‡gêæ¯Ø Instead reads: ..m;{äMã≈P#ü1ˆTMëLÆÖ-«∏4iˇ¯àÚPë‡gêæ¯Ø Notice the extra dot at the beginning of the line... it turns out that ALL the extra dots that gets added are at the beginning of lines, when there is already a dot there Now, that data is downloaded straight from the socket and saved to disk, I am not adding/merging nor doing anything with it so I wonder if it's not a bug with AsyncSocket?? but I guess if it were adding dots all over the place people would've notice it already... I'm out of ideas here really! I could be wrong on this, but assuming you're using NNTP, ISTR it documented to have lines separated by cr+lf? And that the multi- part stuff is based lines separated by those pairs - and if you separate into lines based one only one of them, the extra will get added (erroneously) to the line? Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! Cardographer | the custom playing card designer Jean-Nicolas Jolivet silver...@videotron.ca http://www.silverscripting.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Listening for changes
On Dec 19, 2008, at 11:36 AM, Andre Masse wrote: Hmm.. Thought this would be easy but I'm stuck... Here's what I've done: - added the fake property BOOL needSaving @property(assign, nonatomic) BOOL needSaving; @synthesize needSaving; - implemented keyPathsForValuesAffecting (I'm on Leopard) + (NSSet*)keyPathsForValuesAffectingValueForKey:(NSString*)key { NSSet* set = [super keyPathsForValuesAffectingValueForKey:key]; if ([key isEqualToString:@needSaving]) { set = [set setByAddingObjectsFromSet:[NSSet setWithObjects: @lastName, @firstName, ... nil]]; } return set; } Now, I just can't figure out how I should implement - (BOOL) needSaving! Setting it to NO in -init and implementing it like this obviously doesn't work: - (BOOL) needSaving { return YES; } As I understand this approach, it doesn't matter. All you should need to do is observe the fake property, and in the observeValueForKeyPath call do whatever you need to do. The + keyPathsForValuesAffectingValueForKey: call just (eventually) causes a KVO notice to be sent for the dependent property. So in this approach, you are coalescing all of the individual calls into one call. HTH, Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Listening for changes
Thanks for the explanation. It just works :-) Andre Masse On Dec 19, 2008, at 13:51, Keary Suska wrote: As I understand this approach, it doesn't matter. All you should need to do is observe the fake property, and in the observeValueForKeyPath call do whatever you need to do. The + keyPathsForValuesAffectingValueForKey: call just (eventually) causes a KVO notice to be sent for the dependent property. So in this approach, you are coalescing all of the individual calls into one call. HTH, Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSLog ??
Why can't I find any reference page for NSLog? I believe I have searched all over all documentation that I have and the closest match is NSLogicalTest. I even tried a search using Spotlight on my entire system. I was able to find a usage of NSLog in a program but no documentation hits. Help needed for snowed in beginning Cocoa programmer. -phil- ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSLog ??
On Dec 19, 2008, at 11:18 AM, Phil Hystad wrote: Why can't I find any reference page for NSLog? I believe I have searched all over all documentation that I have and the closest match is NSLogicalTest. I even tried a search using Spotlight on my entire system. I was able to find a usage of NSLog in a program but no documentation hits. Help needed for snowed in beginning Cocoa programmer. I option-double-clicked on the NSLog string in a code window and it was the first hit that came up in the documentation browser. The document it is in is called Foundation Functions Reference. -- Dave Carrigan d...@rudedog.org Seattle, WA, USA PGP.sig Description: This is a digitally signed message part ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSLog ??
On Dec 19, 2008, at 2:18 PM, Phil Hystad wrote: Why can't I find any reference page for NSLog? I believe I have searched all over all documentation that I have and the closest match is NSLogicalTest. I even tried a search using Spotlight on my entire system. I was able to find a usage of NSLog in a program but no documentation hits. http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#/ /apple_ref/c/func/NSLog bunch of useful functions in here. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
[Fwd: Re: [Q] How to let the pasteboard know a file type?]
Because my previoius post contains extra href link, it was not readable. So, I am posting it by removing all format. Original Message Hello. I found out that NSCreateFilenamePboardType() would help. So, I tried it like : My code example is : In awakeFromNib NSString *quicktimeFileNamesPboardType = NSCreateFilenamePboardType(@mov); [myNSTableView registerForDraggedTypes:[NSArray arryWithObject:quickTimeFileNamesPboardType]]; In -tableView:writeRowsWithIndexes:toPasteboard: NSString *quicktimeFileNamesPboardType = NSCreateFilenamePboardType(@mov); anIndex = [selectedRowsIndexSet firstIndex]; while( anIndex != NSNotFound ) { fileName = [NSString stringWithFormat:@%@/%...@.mov, configPath, [[dataArray objectAtIndex:anIndex] name]]; [fileNamesArray addObject:fileName]; // Next index anIndex = [selectedRowIndexSet indexGreaterThanIndex:anIndex]; } [pboard declareTypes:[NSArray arrayWithObjects:quicktimeFilenamesPboardType, nil] owner:nil]; isSuccessful = [pboard setPropertyList:fileNamesArray forType:quicktimeFilenamesPboardType]; ... When I check what information is exported from my program with the Drag Peeker X, it shows : Item Reference: 19884c10 Item Bounds (tlbr): { 86, 1, 104, 191 } Number of flavors: 0 Strangely, it doesn't have any flavor of data. Is there anything wrong how I use the NSCreateNSFilenamePboardType? How to use it properly? Thank you in advance. P.S. By the way, is it normal to put 'furl' and 'hfs' flavor when NSFilenamesPboardType is used? Because an array of file names are added to the pasteboard, I thought that only file name strings were added. But it turned out no-so-true. JongAm Park wrote: Hi, Thanks to a utility program, called DragPeeker X, I found out some clue why the FCP treated dragged file as a file with unknown type. When I dragged the same file from the Finder to the FCP, it shows : Number of Items: 1 1. Item Reference: 19884c10 Item Bounds (tlbr): { 86, 1, 104, 191 } Number of flavors: 2 1.Flavor Type: 'furl' Flavor Flags: 0 Length: 54 Data: 66 69 6C 65 3A 2F 2F 6C 6F 63 61 6C 68 6F 73 74 file://localhost 2F 56 6F 6C 75 6D 65 73 2F 31 37 32 2E 31 36 2E /Volumes/172.16. 32 34 36 2E 31 34 36 2F 4D 4F 56 2F 30 30 30 33 246.146/MOV/0003 59 42 2E 6D 6F 76 YB.mov2.Flavor Type: 'hfs ' Flavor Flags: 300 Length: 80 Data: 4D 6F 6F 56 3F 3F 3F 3F 00 00 FF 98 00 00 00 13 MooV 0A 30 30 30 33 59 42 2E 6D 6F 76 DC 00 00 00 00 .0003YB.mov. FF FF FF FF 00 00 00 00 00 25 F0 A0 A0 31 60 34 .%...1`4 91 F6 C0 A0 BF FF DA 80 84 04 20 42 91 F6 6B 44 .. B..kD 91 F6 C0 A0 00 86 B4 00 17 BB 17 FC BF FF DA C4 But if I drag one from my application to the FCP, it shows : Number of Items: 1 1. Item Reference: c0c0a Item Bounds (tlbr): { 219, 244, 219, 244 } Number of flavors: 2 1.Flavor Type: 'furl' Flavor Flags: 0 Length: 54 Data: 66 69 6C 65 3A 2F 2F 6C 6F 63 61 6C 68 6F 73 74 file://localhost 2F 56 6F 6C 75 6D 65 73 2F 31 37 32 2E 31 36 2E /Volumes/172.16. 32 34 36 2E 31 34 36 2F 4D 4F 56 2F 30 30 30 33 246.146/MOV/0003 59 42 2E 6D 6F 76 YB.mov2.Flavor Type: 'hfs ' Flavor Flags: 0 Length: 80 Data: 00 00 00 00 00 00 00 00 00 00 FF 98 00 00 00 13 0A 30 30 30 33 59 42 2E 6D 6F 76 FC 00 25 DB A0 .0003YB.mov..%.. 00 00 00 06 00 18 80 00 00 00 00 60 00 25 8E B0 ...`.%.. 90 10 7A 44 BF FF DA 70 44 04 20 42 90 10 7D EC ..zD...pD. B..}. 00 00 00 02 BF FF DA 90 00 00 00 20 BF FF DC F4 ... ( I also tried NSURLPboardType and NSFileContentsPboardType. But they didn't make information like above appear. ) The PboardType I used was NSFilenamesPboardType. The major difference between those are in the 2nd flavor type 'hfs'. Their flavor flags are different: one is 300, while the other is 0. What actually matters, I think, is the data of the 2nd flavor. The one using the Finder starts with MooV, which says that the dragged item is a QuickTime movie, while the one from my application doesn't contain anything. ( all 0's. ) So, is there any way to mark that the interested file is in a specific type, i.e. QuickTime movie file? Thank you. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list.
Re: NSLog ??
On Dec 19, 2008, at 12:18 PM, Phil Hystad wrote: Why can't I find any reference page for NSLog? I believe I have searched all over all documentation that I have and the closest match is NSLogicalTest. I even tried a search using Spotlight on my entire system. I was able to find a usage of NSLog in a program but no documentation hits. Help needed for snowed in beginning Cocoa programmer. -phil- In the Developer Documentation window on the left hand side, make sure you have the correct Doc Set selected. Either Core Library under Apple Mac OS X or iPhone OS Library under Apple iPhone OS. Alternatively, just under the toolbar, select All Doc Sets. --Nathan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSData downloaded over socket is bigger than it should be...
On 19 Dec 08, at 10:24, Jean-Nicolas Jolivet wrote: Well after comparing the data that I am receiving with the data that I SHOULD be receiving, it turns out that dots (yes, the dot character (.) ) are added all over the place in the data if I have 10 extra bytes, it means 10 extra dots were added to my data, so for example, a line that SHOULD read: .m;{äMã≈P#ü1ˆTMëLÆÖ-«∏4iˇ¯àÚPë‡gêæ¯Ø Instead reads: ..m;{äMã≈P#ü1ˆTMëLÆÖ-«∏4iˇ¯àÚPë‡gêæ¯Ø Notice the extra dot at the beginning of the line... it turns out that ALL the extra dots that gets added are at the beginning of lines, when there is already a dot there RFC 977, section 2.4.1 states: If the text contained a period as the first character of the text line in the original, that first period is doubled. Therefore, the client must examine the first character of each line received, and for those beginning with a period, determine either that this is the end of the text or whether to collapse the doubled period to a single one. You'll need to check for and remove these characters yourself.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSData downloaded over socket is bigger than it should be...
On 19 Dec 2008, at 18:43, Jean-Nicolas Jolivet wrote: I am indeed using NNTP, but really I'm not even looking at cr+lf etc... Basically I'm sending the following command to retrieve a message: ARTICLE message-id\r\n Then I'm reading all the data up until \r\n.\r\n is found (that is, a new line, a dot, and a new line again) which marks the end of an email and I'm saving that data to the disk mmm, now that I say it like that though a dot on a newline marks the end of a message... and my problem is that I have dot inserted on new lines? can't be a coincidence!... but then again, I'm using AsyncSocket's readToData function... so I don't have much control over that... As you have access to the source you have as much control over it as anyone else has! The data checking termination code is in AsyncSocket.m - (void)doBytesAvailable. A bit of diligent poking in there might help. Jean-Nicolas Jolivet silver...@videotron.ca http://www.silverscripting.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/jonathan%40mugginsoft.com This email sent to jonat...@mugginsoft.com Jonathan Mitchell Central Conscious Unit http://www.mugginsoft.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSLog ??
On Dec 19, 2008, at 2:18 PM, Phil Hystad wrote: Why can't I find any reference page for NSLog? In addition to the search methods others have suggested, you could also Google for nslog site:developer.apple.com, which works really well for searching for Cocoa info in general. In addition, my free doc browser AppKiDo would have found NSLog right away. http://homepage.mac.com/aglee/downloads/appkido.html --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 arch...@mail-archive.com
populate/resize an already open NSMenu in background
Hi everyone, I have a menu that needs to be populated on demand, so I've set an NSMenu delegate and note the update request in menuNeedsUpdate:. The problem is that populating the menu can take quite a while, so results need to be generated in the background and then added as they come in. Think of something like the system Spotlight menu, where file matches are appended as they are found. The problem is that the NSMenu will not resize itself to show items added from outside of menuNeedsUpdate:. If I call update and/or resizeToFit the menu does change its display to show the changed/ reordered items, but never resizes itself beyond the capacity established in menuNeedsUpdate. Has anyone ever gotten this kind of thing to work? I do notice that moving the mouse to hide the menu and then reshow it allows the NSMenu to resize itself as needed. Perhaps I should look into faking mouse events to trigger this kind of thing programmatically- seems like a horrible hack. Thanks for any advice, ~Martin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Determining width of a cell in an NSOutlineView
I only have a single column in my NSOutlineView. The outline view looks like: Collapsible Row 1 Item 1 Collapsible Row 2 Item 2 I need the height of a row an of an item displayed when the disclosure triangle is clicked to be based on the width of the cell. I can get the indentation level by doing: NSInteger level = [outlineView levelForItem:item]; and the amount that is indented per level by doing: CGFloat indentation = [outlineView indentationPerLevel]; Asking for the width of the column does not return the same width of the bounds parameter when drawInteriorWithFrame is called for my cell. What looks like could work is to get the frame of the NSOutlineView and then subtract the width of the frame by: indentation * (level + 1) but this doesn't seem like it should be the right answer. There doesn't seem to be a method I can call to obtain the bounds that will be passed into drawInteriorWithFrame for my cell. Have I missed something? Any other ideas? thank you. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Determining width of a cell in an NSOutlineView
On Dec 19, 2008, at 1:35 PM, Eric Gorr wrote: I only have a single column in my NSOutlineView. The outline view looks like: Collapsible Row 1 Item 1 Collapsible Row 2 Item 2 I need the height of a row an of an item displayed when the disclosure triangle is clicked to be based on the width of the cell. I can get the indentation level by doing: NSInteger level = [outlineView levelForItem:item]; and the amount that is indented per level by doing: CGFloat indentation = [outlineView indentationPerLevel]; Asking for the width of the column does not return the same width of the bounds parameter when drawInteriorWithFrame is called for my cell. What looks like could work is to get the frame of the NSOutlineView and then subtract the width of the frame by: indentation * (level + 1) but this doesn't seem like it should be the right answer. There doesn't seem to be a method I can call to obtain the bounds that will be passed into drawInteriorWithFrame for my cell. Have I missed something? -frameOfCellAtColumn:row: is exactly what will be passed to your cell. corbin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cocoa Apple Script Problem
Hi John- If you are on Leopard, try taking a look at the documentation for the following method: - (id)newScriptingObjectOfClass:(Class)class forValueForKey:(NSString *)key withContentsValue:(id)contentsValue properties:(NSDictionary *)properties; The Cocoa Scripting Guide refers to the Leopard Foundation Release Notes in a number of places for the latest info, and that I where I found out about this method (http://developer.apple.com/releasenotes/Cocoa/Foundation.html#Scripting). In short, one implements this method on the containing object, which then allows you to read the properties dictionary and configure your newly made object before it gets added (via insertObject:inKeyAtIndex:) to the container object. There is a lot of new scripting material in those release notes; should be helpful to your scripting efforts. Hope this helps! John Positive Spin Media http://www.positivespinmedia.com On Fri, 19 Dec 2008 10:11:19 -0800, John Nairn j...@geditcom.com wrote: I have implemented the required methods to support creating an object in Apple Script, but it does not work as advertised. This does work as expected tell front document make new family at end tell last family set properties to {husband:@I5@} end tell end tell This creates the object but does NOT set the properties tell front document make new family at end with properties {husband:@I5@} end tell The family objects are tied to key-value methods using key = famRecords in my suite and the method getting called by both these make commands is - (void)insertInFamRecords:(id)object where object is the correct FAMRecord type. If set properties to works on an existing object, shouldn't it work when creating a new one? Do have to manuul find a way to override the make command? Curiously this method of form insertInKeyRecords: is not even mentioned in the Key-Value Coding and Cocoa Scripting section of the Cocoa Scripting Guide. I had to find it by an error message in the Console before it was present. --- John Nairn GEDitCOM - Genealogy Software for the Macintosh http://www.geditcom.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Determining width of a cell in an NSOutlineView
On Dec 19, 2008, at 5:20 PM, Corbin Dunn wrote: On Dec 19, 2008, at 1:35 PM, Eric Gorr wrote: I only have a single column in my NSOutlineView. The outline view looks like: Collapsible Row 1 Item 1 Collapsible Row 2 Item 2 I need the height of a row an of an item displayed when the disclosure triangle is clicked to be based on the width of the cell. I can get the indentation level by doing: NSInteger level = [outlineView levelForItem:item]; and the amount that is indented per level by doing: CGFloat indentation = [outlineView indentationPerLevel]; Asking for the width of the column does not return the same width of the bounds parameter when drawInteriorWithFrame is called for my cell. What looks like could work is to get the frame of the NSOutlineView and then subtract the width of the frame by: indentation * (level + 1) but this doesn't seem like it should be the right answer. There doesn't seem to be a method I can call to obtain the bounds that will be passed into drawInteriorWithFrame for my cell. Have I missed something? -frameOfCellAtColumn:row: is exactly what will be passed to your cell. Unfortunately, this does not work as calling this function causes heightOfRowByItem to be called. So, an endless loop is entered. I just need to know the width so I base the height on the width. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
[Q] How will the Pasteboard manager be changed?
Hello. I'm implementing some logic to enable drag from my application's NSTableView and drop on the Final Cut Pro's project. I found out that it was not possible with NSFilenamesPboardType. When I compared it a dragdrop from the Finder to the FCP, the one between the Finder and the FCP contained fURL and hfs flavors and its hfs flavor data showed that the dragged item was a QuickTime movie, while the one between from my program and the Finder contained same kind of data but its hfs flavor didn't show that it was a QuickTime movie. So, I tried using NSCreateFilenamePboardType( @mov ) and NSCreateFilenamePboardType( (NSString *)kUTTypeQuickTimeMovie ); but they didn't allow the dragdrop. Although the default NSFilenamesPboardType generates fURL and hfs flavor, the one from NSCreateFilenamePboardType() doesn't generate them. So, I started thinking that mechanism using NSCreateFilenamePboardType() is on its way to death. So, I read Apple's document further, and found out that the Carbon's pasteboard manager dropped many functions like something related to flavors. Almost all functions are deprecated, and it gave me feeling that probably the Carbon's pasteboard manager would work like that of Cocoa. (Well, eventually Carbon would die, but.. at least 64bit support on the Carbon and GUI support look so. ) So, I wonder if I really give up dragdrop from my application and the FCP. The FCP looks like a Carbon app. So, I may need to write carbon code to put hfs flavor. But I doubt if it is worth while to doing so. So, can anyone tell me how the Carbon's pasteboard manager will change, and why Cocoa's pasteboard manager doesn't reveal some methods which handles flavors easily? Probably flavors are being deprecated also? ( Although there should be some similar mechanism.. ) I will appreciate any comment. Thank you. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [Q] How will the Pasteboard manager be changed?
On Dec 19, 2008, at 5:39 PM, JongAm Park wrote: So, can anyone tell me how the Carbon's pasteboard manager will change, and why Cocoa's pasteboard manager doesn't reveal some methods which handles flavors easily? Probably flavors are being deprecated also? ( Although there should be some similar mechanism.. ) The preferred, mechanism independent way, to describe types on Mac OS X is to describe them via a Uniform Type Identifier (UTI). Most places in AppKit should transparently support UTIs on 10.5 and later. If you need to interact with the pasteboard on earlier releases, you'll have to drop down to the procedural API in Pasteboard.h. If you have a four char code that you need to represent as a UTI, you can do the conversion using the functions in UTType.h. Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Determining width of a cell in an NSOutlineView
On Dec 19, 2008, at 2:30 PM, Eric Gorr wrote: On Dec 19, 2008, at 5:20 PM, Corbin Dunn wrote: On Dec 19, 2008, at 1:35 PM, Eric Gorr wrote: I only have a single column in my NSOutlineView. The outline view looks like: Collapsible Row 1 Item 1 Collapsible Row 2 Item 2 I need the height of a row an of an item displayed when the disclosure triangle is clicked to be based on the width of the cell. I can get the indentation level by doing: NSInteger level = [outlineView levelForItem:item]; and the amount that is indented per level by doing: CGFloat indentation = [outlineView indentationPerLevel]; Asking for the width of the column does not return the same width of the bounds parameter when drawInteriorWithFrame is called for my cell. What looks like could work is to get the frame of the NSOutlineView and then subtract the width of the frame by: indentation * (level + 1) but this doesn't seem like it should be the right answer. There doesn't seem to be a method I can call to obtain the bounds that will be passed into drawInteriorWithFrame for my cell. Have I missed something? -frameOfCellAtColumn:row: is exactly what will be passed to your cell. Unfortunately, this does not work as calling this function causes heightOfRowByItem to be called. So, an endless loop is entered. Yes, of course...since it needs to know the height, but it does answer your question of how to obtain the bounds that are passed to drawInteriorWithFrame:. I just need to know the width so I base the height on the width. For that, you want to use -cellSizeForBounds: -- pass in a large height, but a constrained width. Use a width that is equal to the [tableColumn width] minus indentation * (level + 1) although, the actual value that outlineview uses for indentation is dependent on some internal logic (ie: if you are using group rows, or the source list highlighting style). But, this should give you a value that is fairly close to what you want. corbin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Optimizing NSRectFill
On 20 Dec 2008, at 2:37 am, Oleg Krupnov wrote: I'm developing a custom view and noticed that drawRect is becoming increasingly slow. The Shark has pointed out that the bottleneck is the NSRectFill function (that calls CGContextFillRect under the hood) that I use to draw the background of the view. I am disappointed that such a basic operation could ever impair performance, but it does. It looks like the bigger is the rectangle, the slower is performance. I have read the list regarding this issue, but I haven't found any solution. NSRectFillList, CGContextFillRect do not give any performance gain. My question is - is there a way to bypass the advanced path-related stuff that causes the slow-down, and just get down to some kind of fast drawing? Show your code. As Bill suggests, there's no way that NSRectFill is slow. If Shark is pointing the finger at it, it's probably because you are calling it much more often than necessary. --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Optimizing NSRectFill
On Dec 19, 2008, at 7:37 AM, Oleg Krupnov wrote: I'm developing a custom view and noticed that drawRect is becoming increasingly slow. The Shark has pointed out that the bottleneck is the NSRectFill function (that calls CGContextFillRect under the hood) that I use to draw the background of the view. A common cause of apparently excessive time in graphics related ops is that you are running afoul of coalesced updates by attempting to refresh faster than 60 times a second. See http://developer.apple.com/documentation/Performance/Conceptual/Drawing/Articles/FlushingContent.html . Try disabling coalesced updates in Quartz Debug and see if it speeds up your drawing. If so, ensure your app does not refresh faster than 60 Hz. -Peter ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: populate/resize an already open NSMenu in background
On Dec 19, 2008, at 1:21 PM, Martin Wierschin wrote: Hi everyone, I have a menu that needs to be populated on demand, so I've set an NSMenu delegate and note the update request in menuNeedsUpdate:. The problem is that populating the menu can take quite a while, so results need to be generated in the background and then added as they come in. Think of something like the system Spotlight menu, where file matches are appended as they are found. The problem is that the NSMenu will not resize itself to show items added from outside of menuNeedsUpdate:. If I call update and/or resizeToFit the menu does change its display to show the changed/reordered items, but never resizes itself beyond the capacity established in menuNeedsUpdate. Has anyone ever gotten this kind of thing to work? I do notice that moving the mouse to hide the menu and then reshow it allows the NSMenu to resize itself as needed. Perhaps I should look into faking mouse events to trigger this kind of thing programmatically- seems like a horrible hack. It should not be necessary to fake mouse events. A common cause of failure is that your menuNeedsUpdate: call leaves the menu empty. A user cannot select from an empty menu, so menu tracking just ends in that case. Make sure the menu item has at least one item, such as Building..., after the call to menuNeedsUpdate:. Another possible cause is that you are populating the menu with a timer or some run loop source that is only added in the default or common run loop mode. Menu tracking happens in NSEventTrackingRunLoopMode; make sure any timers you have that you want to fire are added to the run loop in this mode. A third possible cause is that you're on Tiger. Changing a menu while it is open is only supported on Leopard. If that doesn't solve it for you, please put together a sample showing the problem and I'll take a look. -Peter ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [Q] How will the Pasteboard manager be changed?
Thanks for your comment. Although the AppKit supports UTIs, but I couldn't find a way to generate pasteboard type for 'hfs'. So, probably for this, I think Carbon functions should be used. There are only two functions in the AppKit for making file type specific Pboard : NSCreateFileContentsPboardType() and NSCreateFilenamePboardType(). Although NSFilenamesPboardType yield 'fURL' and 'hfs' flavors, using returned string by calling NSCreateFileContentsPboardType() doesn't generate any flavors. So, I had to find a way to generate the 'hfs' using the Cocoa, but I guess I need to use Carbon functions. By the way, can the Pasteboard type and NSPasteboard be intermixed like CFStringRef and NSString? Thanks, JongAm Park Jim Correia wrote: On Dec 19, 2008, at 5:39 PM, JongAm Park wrote: So, can anyone tell me how the Carbon's pasteboard manager will change, and why Cocoa's pasteboard manager doesn't reveal some methods which handles flavors easily? Probably flavors are being deprecated also? ( Although there should be some similar mechanism.. ) The preferred, mechanism independent way, to describe types on Mac OS X is to describe them via a Uniform Type Identifier (UTI). Most places in AppKit should transparently support UTIs on 10.5 and later. If you need to interact with the pasteboard on earlier releases, you'll have to drop down to the procedural API in Pasteboard.h. If you have a four char code that you need to represent as a UTI, you can do the conversion using the functions in UTType.h. Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSTextList - need help
hi all, I would like to use bullets and numberings in the textview . I found some of search results for this topic ,they were about NSTextList . How can it be implemented. please provide me some help on NSTextList. thank you Regards.. rethish ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Enabling add button
I did something like this once. I'm not sure if this is a good way to tackle the problem or not but here's what you need: - A BOOL ivar exposed as a property on one of your controllers: BOOL isTableViewSelected; @property(assign) BOOL isTableViewSelected; @synthesize isTableViewSelected; - Next, set up an observer of NSWindowDidUpdateNotification in - awakeFromNib or somewhere else so we can watch for any changes in the window (like first responder changing): [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkFirstResponderStatusNotification:) name:NSWindowDidUpdateNotification object:[aView window]]; // -- Get to the main window somehow - In the selector for the notification check the class of the first responder and then set the isTableViewSelected ivar accordingly. By using the synthesized setter it broadcasts change notifications so you can bind the 'Enabled' binding of the button to yourController.isTableViewSelected and it should then update its status correctly as you move around your UI. - (void)checkFirstResponderStatusNotification:(NSNotification *)note { NSWindow *mainWindow = [self.aView window]; // -- Get to the main window somehow self.isTableViewSelected = ([[mainWindow firstResponder] isKindOfClass:[NSTableView class]]); } I think this should work, you'll probably have to fiddle about with some things (I originally used this to check the class of one of my own classes, not a table view). I think there was some weird problems with flickering (rapid on/off changes?) when a sheet was present on the window which I never got round to solving, ymmv. (Also [[NSNotificationCenter defaultCenter] removeObserver:self]; in - dealloc or elsewhere) On 18 Dec 2008, at 23:28, Andre Masse wrote: On Dec 18, 2008, at 15:43, I. Savant wrote: The issue Andre mentioned is that the app is mostly keyboard-driven (and the key combo fires the button, which he fears can be triggered inadvertently). This means it doesn't matter where the button is - the key combo can still trigger the action without calling enough attention to the resulting insert. Exactly. You're way better than me explaining my own problems :-) I used to talk/write English much more 5-6 years ago (even co- translated a book from French to English). Now, I only use English in this list and it shows :-) Thanks, Andre Masse ___ 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/blue.buconero%40virgin.net This email sent to blue.bucon...@virgin.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Core Data File Encryption
Hello, I'm just beginning to learn Cocoa programming and I'm having some trouble figuring out how to encrypt a persistent data store transparently. I'm trying to write a Core Data (not document based) application and it needs to store the data in a file encrypted with AES. I found out about CDSA which I'm planning on using for the actual encryption and decryption of the data but I haven't the slightest idea how to find out what methods my subclass needs to override. I was thinking placing the encryption between archiving the data and actually writing it to the disk but I'm not quite sure how to do that. Some kind of sample code would be much appreciated along with maybe some advice/info for how to find this kind of information on my own as I don't particularly like bothering people with simple questions on mailing lists but I've exhausted every other resource readily available. I've look at the NSPersistentStore, NSPersistantStoreCoordinator class references, the Core Data Programming Guide and the Low-Level Core Data Tutorial along with searching the mailing lists with no luck finding what I need. Thanks, Chris Benedict ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTreeController rearrangeObjects doesn't always trigger sorting
I'm pleased to see that this has been fixed in 10.5.6 and it's all sorting properly again. Many thanks to Apple's engineers for this. On 4 Oct 2008, at 12:57, Alexey Zakhlestin wrote: I see this behaviour since 10.5.3. (10.5.2 was ok) My solution is manual re-sorting, for now. On Tue, Jul 29, 2008 at 2:41 AM, Jonathan Fewtrell jonathanfewtr...@mac.com wrote: I have a Core Data app with an NSOutlineView controlled by an entity-mode NSTreeController bound to the managed object context. The NSTreeController has sort descriptors based on certain attributes of the model object. Sorting does take place when the frameworks seem to think fit (for example when a document is opened), but if I call -rearrangeObjects to force a sort programmatically nothing happens. Actually, if I tick 'Uses Lazy Fetching' in the controller's IB attributes, the view will sort the first level of nodes, but not the deeper levels. Sorting was working fine in earlier versions of the OS. I'm now in 10.5.4 and I'm not certain which version introduced this problem. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Newbie Question: implementing a stack
Hi All, I am new to this list and new to mac programming as well. I am working on implementing a stack as a category of NSMutableArray. I want this stack to be able to store objects. This is what I have so far: // // Stack.h // Stack implements a basic stack object in an NSMutableArray object. #import Foundation/Foundation.h @interface NSMutableArray (Stack) -(void)push:(id)obj;//push obj of on the stack -(id)pop; //pop top item off the stack -(id)peek; //look at the top item on the stack -(void)clear; //remove all objects from the stack -(NSUInteger)size; //return the number of items on the stack @end // // Stack.m // Stack #import Stack.h @implementation NSMutableArray (Stack) -(void)push:(id)obj { [self addObject:obj]; } -(id)pop { id popedObj; if([self count]) { popedObj = [[[self lastObject] retain] autorelease]; [self removeLastObject]; } else { popedObj = nil; } return popedObj; } -(id)peek; //look at the top item on the stack { return [self lastObject]; } -(void)clear; //remove all objects from the stack { [self removeAllObjects]; } -(NSUInteger)size; //return the number of items on the stack { return [self count]; } @end My question involves storing objects on the stack. As I understand it when I store an object on the stack, I am simply storing a pointer to the object on the stack. If I create an NSString object called foo and do the following: NSString *foo = [[NSString alloc] initWithString:@foo text]; [FractionStack push:foo]; I have put a copy of the pointer to foo on the stack. If I now change foo, the top element on the stack changes also. I do not want this to happen but I am not sure as to the best approach to make sure this does not happen. Would it be best to copy the object to another object - say fooCopy then push fooCopy on the stack? Or would it be better to copy the object inside of the push method? And either way, I am struggling with memory management. If I first copy foo to fooCopy before placing it on the stack then I release fooCopy, will the element on the stack still be able to reference it? do I need to retain it in my push method? Also, I am thinking I likely will need to release these objects when I pop them and when I clear the stack. Is that correct? I am really trying to get my head wrapped around this but I have been struggling with this for some time. If, in addition to some words of wisdom, you can point me in the direction of how I could create a simple test of this in my code to work things out on my own that would be appreciated also. As I said I am new to this so if my post is not in keeping with the way things work on this list please let me know. Thanks in advance, 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 arch...@mail-archive.com
Re: [Q] How will the Pasteboard manager be changed?
On Dec 19, 2008, at 6:59 PM, JongAm Park wrote: Although the AppKit supports UTIs, but I couldn't find a way to generate pasteboard type for 'hfs'. So, probably for this, I think Carbon functions should be used. I previously offered a solution for this problem. I wrote: If you have a four char code that you need to represent as a UTI, you can do the conversion using the functions in UTType.h. These are neither Carbon nor Cocoa functions, but part of the Launch Services framework/API. Among other things, this API set lets you convert between UTI, filename extension, mime type, four character code, and NSPasteboard type. UTTypeCreatePreferredIdentifierForTag is where you should start. (But familiarizing yourself with, and understanding, the API in that header will be beneficial if you find yourself needed to convert between UTI and the various tag classes.) By the way, can the Pasteboard type and NSPasteboard be intermixed like CFStringRef and NSString? No. They are not toll-free bridged. Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Drawing in a NSView out side of drawRect
I want to draw in a NSView but not when drawRect is called. To do this I understand that I need to call lockFocus before drawing and unlockFocus after. The drawing appears to happen but it is not until I deactivate the window do I see my results. How can I get it to refresh once I have done my drawing? To test this out I have sub classed NSView and overloaded mouseDown. I added the following code. - (void)mouseDown:(NSEvent *)theEvent ; { NSPoint loc = [[self window] mouseLocationOutsideOfEventStream]; loc = [self convertPoint:loc fromView:[[self window] contentView]]; CGContextRef myContext = (CGContextRef)[[NSGraphicsContext currentContext]graphicsPort]; [self lockFocus]; CGContextSetRGBFillColor (myContext, 1, 0, 0, 1); CGContextFillRect (myContext, CGRectMake (loc.x, loc.y, 10, 10 )); [self unlockFocus]; } This will draw a box for each mouse click, but not until I deactivate my window. thanks for the help -dave ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Listening for changes
Since you apparently want to just know that one of the fields changed, but not which one specifically, why not just have the class post an NSNotification called MyClassDidChange or similar? Mike. On 19 Dec 2008, at 17:06, Andre Masse wrote: Let's say I have a class (called it Client) that has 25 fields and need to be notified when any of these is modified. Do I have to do - observeValueForKeyPath for each of the 25 fields? Thanks, Andre Masse ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net This email sent to cocoa...@mikeabdullah.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Newbie Question: implementing a stack
On Dec 19, 2008, at 1:22 PM, Steve Wetzel wrote: I am new to this list and new to mac programming as well. I am working on implementing a stack as a category of NSMutableArray. I want this stack to be able to store objects. This is what I have so far: // // Stack.h // Stack implements a basic stack object in an NSMutableArray object. #import Foundation/Foundation.h @interface NSMutableArray (Stack) -(void)push:(id)obj;//push obj of on the stack -(id)pop; //pop top item off the stack -(id)peek; //look at the top item on the stack -(void)clear; //remove all objects from the stack -(NSUInteger)size; //return the number of items on the stack @end If I were doing this, I would actually create an object (subclass of NSObject) that would contain an NSMutableArray as an attribute. That way, your API would be very clean. What you have above would allow users to call any of the NSArray* suite of APIs in addition to yours above. Sometimes too many APIs on an object can lead to issues. My question involves storing objects on the stack. As I understand it when I store an object on the stack, I am simply storing a pointer to the object on the stack. If I create an NSString object called foo and do the following: NSString *foo = [[NSString alloc] initWithString:@foo text]; [FractionStack push:foo]; I have put a copy of the pointer to foo on the stack. If I now change foo, the top element on the stack changes also. I do not want this to happen but I am not sure as to the best approach to make sure this does not happen. In this specific case, you cannot change foo since NSString is immutable. If you find yourself adding (pushing) items that are immutable, it would be best to make a copy or mutable copy as needed. Also, I am thinking I likely will need to release these objects when I pop them and when I clear the stack. Is that correct? Just read up more on the memory management rules. You can also decide on object-ownership rules. Typically, the container objects retain objects added to them. Then release them when removed. That's all you should be concerned about. It's then up to the original owner of the object to do the right thing. ___ Ricky A. Sharp mailto:rsh...@instantinteractive.com Instant Interactive(tm) http://www.instantinteractive.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Using NSURL authentication APIs for non-standard protocols
Has anyone had much luck using the NSURL authentication APIs for anything outside of http, https, ftp and ftps? The first problem I ran into is that when creating an NSURLProtectionSpace object, specifying ftp as the protocol gets converted to ftps. Likewise, trying to use ssh - http or https Secondly, I have a password stored in the keychain for my ssh account. if I use -[NSURLCredentialStorage allCredentials], I can see that it's not being recognized. Only http, https, ftp and ftps items appear to be picked up. Any ideas for how I could work around this or do I need to use the standard keychain APIs? Mike. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Drawing in a NSView out side of drawRect
On Dec 19, 2008, at 6:20 PM, David Alter wrote: I want to draw in a NSView but not when drawRect is called. To do this I understand that I need to call lockFocus before drawing and unlockFocus after. The drawing appears to happen but it is not until I deactivate the window do I see my results. How can I get it to refresh once I have done my drawing? To test this out I have sub classed NSView and overloaded mouseDown. I added the following code. - (void)mouseDown:(NSEvent *)theEvent ; { NSPoint loc = [[self window] mouseLocationOutsideOfEventStream]; loc = [self convertPoint:loc fromView:[[self window] contentView]]; CGContextRef myContext = (CGContextRef)[[NSGraphicsContext currentContext]graphicsPort]; [self lockFocus]; CGContextSetRGBFillColor (myContext, 1, 0, 0, 1); CGContextFillRect (myContext, CGRectMake (loc.x, loc.y, 10, 10 )); [self unlockFocus]; } This will draw a box for each mouse click, but not until I deactivate my window. What you should do is do all drawing in drawRect:. What happens when your drawRect: is called? I bet you won't see any of the rects you had when clicking around. Instead, maintain a list of rects that need to be drawn. mouseDown: then simply adds a new rect to the list and calls setNeedsDisplay:. Or, if you profile things and need more speed, setNeedsDisplayInRect: If you want things such that only one rect ever is drawn, just have mouseDown: set the values of that single rect and still call setNeedsDisplay: ___ Ricky A. Sharp mailto:rsh...@instantinteractive.com Instant Interactive(tm) http://www.instantinteractive.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Using runtime functions to match up object types safely when setting properties
In my app, I have an interface and code that allows the user to set up different values that can be set as properties of an object. The user is presented with a list of properties that can be set (suitably converted for display in the UI) and then they can set up the values of these properties, which can be one of five distinct types (a custom type, an image, colour, string or numeric value). I'd like to be able to gently prevent the user from making an inappropriate choice. For example if the given property expects a string, they should not be able to choose an image object. Internally, I use KVC, specifically -setValue:forKey: to apply the chosen object to the chosen property. So I'm looking for a way to safely and reliably determine whether a property will accept an object of a given type. I wrote this category on NSObject as a simple wrapper on the runtime to attempt this, but it doesn't work quite how I expected - any property that returns an object simply returns '@' as its return type - I can't tell what class it is. Can anyone point me in the right direction? @implementation NSObject (RuntimeEnhancements) - (NSString*) returnTypeOfPropertyNamed:(NSString*) aProperty { NSString* result = nil; Method meth = class_getInstanceMethod([self class], NSSelectorFromString(aProperty)); if( meth ) { char* methType = method_copyReturnType( meth ); result = [NSString stringWithUTF8String:methType]; free( methType ); } NSLog(@object %@ (%p) return type: %@, self, self, result ); return result; } - (NSString*) typeOfArgumentAtIndex:(unsigned) indx forMethodNamed: (NSString*) aMethodName { NSString* result = nil; Method meth = class_getInstanceMethod([self class], NSSelectorFromString(aMethodName)); if( meth ) { char* argType = method_copyArgumentType( meth, indx ); result = [NSString stringWithUTF8String:argType]; free( argType ); } NSLog(@object %@ (%p) argument at index %d: %@, self, self, indx, result ); return result; } - (BOOL) propertyNamed:(NSString*) aProperty returnsObjectOfClass: (Class) cl { // tests whether the return type of the property named is the same as the class cl NSString* propType = [self returnTypeOfPropertyNamed:aProperty]; return [propType isEqualToString:NSStringFromClass(cl)]; } @end thanks, Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Drawing in a NSView out side of drawRect
On 20 Dec 2008, at 11:20 am, David Alter wrote: I want to draw in a NSView but not when drawRect is called. Why? There are very few situations when this is required or appropriate. To do this I understand that I need to call lockFocus before drawing and unlockFocus after. The drawing appears to happen but it is not until I deactivate the window do I see my results. How can I get it to refresh once I have done my drawing? You need to flush it to the screen. But don't - it's just not the right way to do drawing. To test this out I have sub classed NSView and overloaded mouseDown. I added the following code. Store the rects to be drawn in a list - your view could own this list for simplicity while you are experimenting. Then invalidate the rect you need to repaint in mouse down. -drawRect: then just iterates over the list and draws those rects that intersect the update area. This is way, way easier than trying to fudge around drawing in a non- standard manner. Learn it and love it. 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 arch...@mail-archive.com
Re: Using runtime functions to match up object types safely when setting properties
On Dec 19, 2008, at 6:53 PM, Graham Cox wrote: In my app, I have an interface and code that allows the user to set up different values that can be set as properties of an object. The user is presented with a list of properties that can be set (suitably converted for display in the UI) and then they can set up the values of these properties, which can be one of five distinct types (a custom type, an image, colour, string or numeric value). I'd like to be able to gently prevent the user from making an inappropriate choice. For example if the given property expects a string, they should not be able to choose an image object. First of all, are you familiar with Key-Value Validation? http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/KeyValueCoding/Concepts/Validation.html So I'm looking for a way to safely and reliably determine whether a property will accept an object of a given type. I wrote this category on NSObject as a simple wrapper on the runtime to attempt this, but it doesn't work quite how I expected - any property that returns an object simply returns '@' as its return type - I can't tell what class it is. Can anyone point me in the right direction? I don't believe this is possible. The @ you're getting is the type encoding for an object pointer. http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/chapter_7_section_1.html Note how it says whether statically typed or typed id. Basically, in Objective-C static typing is purely a compile-time thing. The compiler can use it to check the semantics of your program. However, it's lost after that. It's not baked into the resulting executable. Therefore, the Objective-C runtime can't access it. It just isn't there. I think your only avenue is to implement explicit KVV methods for your properties which have the necessary knowledge to test their type. I suppose you could file a feature request to extend declared properties so they can synthesize a type-checking validation method. Or request a compile-time directive to determine the static type of a method return or a property. (Hmm. gcc has a typeof extension. I wonder if it works in Objective-C.) Good luck, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Using runtime functions to match up object types safely when setting properties
On 20 Dec 2008, at 2:28 pm, Ken Thomases wrote: First of all, are you familiar with Key-Value Validation? http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/KeyValueCoding/Concepts/Validation.html So I'm looking for a way to safely and reliably determine whether a property will accept an object of a given type. I wrote this category on NSObject as a simple wrapper on the runtime to attempt this, but it doesn't work quite how I expected - any property that returns an object simply returns '@' as its return type - I can't tell what class it is. Can anyone point me in the right direction? I don't believe this is possible. The @ you're getting is the type encoding for an object pointer. http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/chapter_7_section_1.html Note how it says whether statically typed or typed id. Basically, in Objective-C static typing is purely a compile-time thing. The compiler can use it to check the semantics of your program. However, it's lost after that. It's not baked into the resulting executable. Therefore, the Objective-C runtime can't access it. It just isn't there. I think your only avenue is to implement explicit KVV methods for your properties which have the necessary knowledge to test their type. I suppose you could file a feature request to extend declared properties so they can synthesize a type-checking validation method. Or request a compile-time directive to determine the static type of a method return or a property. (Hmm. gcc has a typeof extension. I wonder if it works in Objective-C.) Ken, I was only vaguely aware of what KVV was for - it looks like the right way to handle this. So I'll investigate that approach - now I come to read the docs in detail, it definitely sounds like what I need. It will certainly do the trick to prevent a bad property type being set, though that's a little bit after the fact. It's not quite so clear how I could validate a type ahead of time so that I could filter out inappropriate ones - but I'll give it some more thought. On the second point I think you're entirely right - I sort of suspected that might be the case as soon as I saw the results I was getting. thanks, Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Newbie Question: implementing a stack
On Dec 19, 2008, at Dec 19:6:31 PM, Ricky Sharp wrote: On Dec 19, 2008, at 1:22 PM, Steve Wetzel wrote: I am new to this list and new to mac programming as well. I am working on implementing a stack as a category of NSMutableArray. I want this stack to be able to store objects. This is what I have so far: // // Stack.h // Stack implements a basic stack object in an NSMutableArray object. #import Foundation/Foundation.h @interface NSMutableArray (Stack) -(void)push:(id)obj;//push obj of on the stack -(id)pop; //pop top item off the stack -(id)peek; //look at the top item on the stack -(void)clear; //remove all objects from the stack -(NSUInteger)size; //return the number of items on the stack @end If I were doing this, I would actually create an object (subclass of NSObject) that would contain an NSMutableArray as an attribute. That way, your API would be very clean. What you have above would allow users to call any of the NSArray* suite of APIs in addition to yours above. Sometimes too many APIs on an object can lead to issues. My question involves storing objects on the stack. As I understand it when I store an object on the stack, I am simply storing a pointer to the object on the stack. If I create an NSString object called foo and do the following: NSString *foo = [[NSString alloc] initWithString:@foo text]; [FractionStack push:foo]; I have put a copy of the pointer to foo on the stack. If I now change foo, the top element on the stack changes also. I do not want this to happen but I am not sure as to the best approach to make sure this does not happen. In this specific case, you cannot change foo since NSString is immutable. If you find yourself adding (pushing) items that are immutable, it would be best to make a copy or mutable copy as needed. Also, I am thinking I likely will need to release these objects when I pop them and when I clear the stack. Is that correct? Just read up more on the memory management rules. You can also decide on object-ownership rules. Typically, the container objects retain objects added to them. Then release them when removed. That's all you should be concerned about. It's then up to the original owner of the object to do the right thing. Ricky, thank you for the response. I think I agree with your answer on creating stack object, it makes sense. Also you confirmed my thoughts about memory management. Regarding memory management - does it make more sense to copy the object to be pushed from within the Stack object rather then copying it externally before the push call? I am thinking that it does because then that object is encapsulated which is how a stack should really work. If I do this I realize I will need to implement a copy method within any object that I want to place on the stack if it does not already have one. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Drawing in a NSView out side of drawRect
On Fri, Dec 19, 2008 at 7:20 PM, David Alter alterconsult...@gmail.com wrote: I want to draw in a NSView but not when drawRect is called. Others have pointed this out, but I want to reiterate: no you don't. Trying to draw outside of drawRect: will only lead to pain. (It is useful, on rare occasions. You are not experiencing one of them.) Work with the view machinery. Call -setNeedsDisplay:. However, I'll also point out why your code currently doesn't work, just for posterity: CGContextRef myContext = (CGContextRef)[[NSGraphicsContext currentContext]graphicsPort]; Right now you're getting the current graphics context, which is purely arbitrary. Nothing has set it yet, so you're getting whatever happened to be hanging around. [self lockFocus]; Now you lock focus, which sets the current context to the one for your view. Since you grab the context before you set it, things don't work very well. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: getObjects:andKeys
Jordon, this can be used to create copies of a dictionary, you get the keys and values array with getObjects:andKeys on an existing dictionary and iterate through the keys array and setting the same keys and values for a mutable dict. On 17-Dec-08, at 7:06 PM, Jordon Hirshon wrote: Can someone tell me where I might see an example of this method? Thanks, Jordon ___ 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 chaita...@expersis.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: getObjects:andKeys
On Sat, Dec 20, 2008 at 12:20 AM, chaitanya pandit chaita...@expersis.com wrote: Jordon, this can be used to create copies of a dictionary, you get the keys and values array with getObjects:andKeys on an existing dictionary and iterate through the keys array and setting the same keys and values for a mutable dict. Why would you do such an insane thing instead of simply doing [dict mutableCopy]? Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: getObjects:andKeys
Hehe, i know, but he just wanted an example as to what can be done with getObjects:andKeys. This was focused on using the getObjects... method rather than to create a copy of the dict. On 20-Dec-08, at 10:56 AM, Michael Ash wrote: On Sat, Dec 20, 2008 at 12:20 AM, chaitanya pandit chaita...@expersis.com wrote: Jordon, this can be used to create copies of a dictionary, you get the keys and values array with getObjects:andKeys on an existing dictionary and iterate through the keys array and setting the same keys and values for a mutable dict. Why would you do such an insane thing instead of simply doing [dict mutableCopy]? 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/chaitanya%40expersis.com This email sent to chaita...@expersis.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Newbie Question: implementing a stack
On 20 Dec 2008, at 3:15 pm, Steve Wetzel wrote: Regarding memory management - does it make more sense to copy the object to be pushed from within the Stack object rather then copying it externally before the push call? I am thinking that it does because then that object is encapsulated which is how a stack should really work. If I do this I realize I will need to implement a copy method within any object that I want to place on the stack if it does not already have one. My own view is that the stack object shouldn't copy the object. In your particular case you seem to want to push a copy of the object onto the stack, but in the general case, you wouldn't expect the stack to do this. In the interest of developing reusable code where possible, your stack object would be more reusable if it was dumber - i.e. it retained its objects and didn't copy them. If I had a stack object black box, pushed an object then later when I popped it I got back a different object (albeit one that was very similar) I'd be surprised by that, especially if I'd mutated it on purpose - all my changes would have evaporated. In your special case perform the copy outside the stack object, thus keeping the special case out of an otherwise reusable class. That said, over-generalising code prematurely is almost as bad as optimising code prematurely, so if you think you'll never have a use for a stack anywhere else except this one case, then by all means do the copy internally. 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 arch...@mail-archive.com
Re: Newbie Question: implementing a stack
On 20 Dec 2008, at 4:52 pm, Graham Cox wrote: On 20 Dec 2008, at 3:15 pm, Steve Wetzel wrote: Regarding memory management - does it make more sense to copy the object to be pushed from within the Stack object rather then copying it externally before the push call? I am thinking that it does because then that object is encapsulated which is how a stack should really work. If I do this I realize I will need to implement a copy method within any object that I want to place on the stack if it does not already have one. My own view is that the stack object shouldn't copy the object. Of course, a very easy, and generally useful solution, is to provide two methods: - (void)push:(id) obj; - (void)pushCopy:(id) obj; G. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com