Re: D.O. [NSPortCoder sendBeforeTime:sendReplyPort:] timed out
Hey, Did you ever figure out what the problem is? It sounds like I am having the exact same problem. It has been driving me insane for a while now. I can't figure it out for the life of me. Thank You, Bridger Maxwell On Thu, May 22, 2008 at 10:02 PM, R.L. Grigg [EMAIL PROTECTED] wrote: I have a Cocoa DO server and a client that connects to it. When the client orderly exits with [server removeMessageClient:self] the client can reconnect and everything just works. But if the client crashes and then tries to reconnect to the server, the server somehow refuses the request: 2008-05-23 09:33:20.855 client[6621:10b] [NOTE: this exception originated in the server.] [NSPortCoder sendBeforeTime:sendReplyPort:] timed out (10233202800.854183 233202800.854681) 1 Is there some exception the server can detect when a client crashes so it can drop/reset that connection? Or is there some way to do this from the client side when trying to reconnect? The only way I can clear it is to restart the server. Russ Xcode 3.0, OSX 10.5.2, Cocoa ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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/bridgeyman%40gmail.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Asynchronous timers (without a run loop)
Le 6 déc. 08 à 00:22, Påhl Melin a écrit : 2008/12/5 Sherm Pendley [EMAIL PROTECTED]: On Dec 5, 2008, at 3:16 PM, Påhl Melin wrote: 2008/12/5 Sherm Pendley [EMAIL PROTECTED]: You'd have far, far less trouble programming for the Mac if you'd simply learn how Cocoa works, instead of trying to reinvent .NET in Objective-C. When in Rome, do as the Romans do. That's why I asked in the first place. I didn't know how Cocoa works in regards to timers. I understand that - and it's a good point. But consider how you asked the question. If you don't know how Cocoa works, how is it that you've already decided that you shouldn't use a run loop? That's putting the cart in front of the horse, IMHO. The fact that you don't use a run loop to build timers with some other framework doesn't imply that you shouldn't do so when you're using Cocoa. I didn't really decide I shouldn't use a run loop for the timers. I am porting a library from another platform and just wanted a quick answer if I could get a similar timer API behavior in either Cocoa, Core Foundation or BSD Unix (with a preference on low-level for efficiency), What make you think lower level mean more efficient ? Just do it the simple way (CFRunLoopTimer) and if it not efficient enough (after profiling, and testing), think about an other way to do it. But you will hardly find a difference between CFRunLoopTimer which are a very thin wrapper in mach timers, and kevent's timers. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Core Data request predicates and to-many relationships
If there are any NSPredicate gurus out there, I'm scratching my head on this one: I have an entity that can optionally have a set of attributes (name- value pairs). This is set up in the model as a optional to-many relationship to an attribute entity. Now, I want to fetch the list of managed objects of this entity whose attributes exactly match a dictionary that is passed. The predicate for this needs to filter the objects that have all the required attributes; matching both the name, and value for each attribute. At this point I'm not seeing how you can code this in a predicate. If I AND some clauses like: ...ANY attr.name == %@ AND ANY attr.value == [EMAIL PROTECTED] for each attribute I'm testing for, then AFAICS I'm not testing that the _same_ attr has the name and value. I wondered about: ...ANY (attr.name == %@ AND attr.value == %@)... but this doesn't appear to be legal syntax. I'm still experimenting, but if anyone knows how to express a query that allows multiple clauses on the _same_ entity across a to-many relationship I'd appreciate a clue! Cheers Luke ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Reading in XML with iso-8859-1 encoding?
I've got a web based xml file in iso-8859-1 encoding that I'm trying to read into an NSXMLDocument. I've got the following code, but I can't seem to make it work? (I've tried all manner of combinations) //create the url NSString *urlString = [NSString stringWithFormat: @http://www.willowtreecrafts.co.uk/ag/ sesbuddyimport.php]; NSURL *url = [NSURL URLWithString:urlString]; NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30]; //fetch the xml response NSData *urlData; NSURLResponse *response; NSError *error; urlData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:response error:error]; if (!urlData){ NSAlert *alert=[NSAlert alertWithError:error]; [alert runModal]; return; } //parse the xml response [doc release]; [doc setCharacterEncoding:@iso-8859-1]; //NSString *xmlstring = [NSString stringWithContentsOfURL:url usedEncoding:@iso-8859-1 error:error]; doc=[[NSXMLDocument alloc]initWithData:urlData options:0 error:error ]; //doc=[[NSXMLDocument alloc]initWithContentsOfURL:url options:0 error:error]; //doc=[[NSXMLDocument alloc]initWithXMLString:xmlstring options:0 error:error]; I get an error telling me that the input is not in UTF-8 encoding. I know the input isn't UTF-8, but how can I get it to accept the iso-8859-1 file? Thanks ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Fix Populated NSMenu Of Files, Folders And Their Respected Images
thanks ashley, you cleared up a lot for me. however, i'm now presented with two (seemingly) small issues. the first is determining whether the directory is empty. i've added an array with directoryContentsAtPath, and an if statement counting the array, but it doesn't seem to work. second, how is it possible to change the size of the iconForFile(s) using setSize:NSMakeSize(16, 16), or any other way? my updated code follows: -=-=-=-=- - (void)awakeFromNib { NSMenu *desktopMenu = [[NSMenu alloc] initWithTitle:@]; NSMenuItem *desktopItem = [[NSMenuItem alloc] initWithTitle:@Desktop Files action:nil keyEquivalent:@]; [desktopItem setSubmenu:desktopMenu]; NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *desktopDirectory = [@~/Desktop/9 stringByExpandingTildeInPath]; NSDirectoryEnumerator *directoryEnumerator = [fileManager enumeratorAtPath:desktopDirectory]; NSString *fileOrFolder; NSArray *theFolderContents = [fileManager directoryContentsAtPath:desktopDirectory]; if ([theFolderContents count] == 0) { NSLog(@no files); NSMenuItem *noFilesItem = [[NSMenuItem alloc] initWithTitle:@No Files action:nil keyEquivalent:@]; [desktopMenu addItem:noFilesItem]; [noFilesItem release]; } else { while ((fileOrFolder = [directoryEnumerator nextObject])) { //ignore invisible files if ([fileOrFolder hasPrefix:@.]) { continue; } [directoryEnumerator skipDescendents]; NSMenuItem *desktopItems = [[NSMenuItem alloc] initWithTitle:fileOrFolder action:@selector(launchFileOrFolder:) keyEquivalent:@]; [desktopItems setTarget:self]; [desktopItems setRepresentedObject:[desktopDirectory stringByAppendingPathComponent:fileOrFolder]]; [desktopItems setImage:[[NSWorkspace sharedWorkspace] iconForFile:[desktopDirectory stringByAppendingPathComponent:fileOrFolder]]]; [desktopMenu addItem:desktopItems]; [desktopItems release]; } } [theMenu insertItem:desktopItem atIndex:1]; [desktopMenu release]; [desktopItem release]; } - (void)launchFileOrFolder:(id)sender { NSString *filePath = [sender representedObject]; [[NSWorkspace sharedWorkspace] openFile:filePath]; } - (void)dealloc { [super dealloc]; } -=-=-=-=- On Fri, Dec 5, 2008 at 3:07 PM, Ashley Clark [EMAIL PROTECTED] wrote: On Dec 5, 2008, at 9:44 AM, Chunk 1978 wrote: hi. Hi. i've been on this task for almost a week, and i still can't get it right. basically, i would like to have an NSMenu populated with all the files and folders of a specific directory. for this example i'll use ~/Documents. the code below only partially works. it will list files and folders from Documents in an NSMenu, but they are not selectable. i've added a @selector, but it doesn't seem to be called. the selector if just an example method - i don't want to really terminate the app when an item is selected, i simply want the item to launch. You have to also call setTarget: on the menu items so it knows which object to send the message to. In your case you'd probably pass self as the object. Also if you want to access the path again during your selector it would probably be easiest to set the path for the item as the representedObject. NSMenuItem *item = /* your item with @selector */ [item setTarget:self]; [item setRepresentedObject:[documentsDirectory stringByAppendingPathComponent:fileOrFolder]]; Then in your method: - (void)actionMethod:(id)sender { id fullPath = [sender representedObject]; /* do something with fullPath */ } second, it would be ideal to have the folders also produce their own NSMenu list of files contained in them - i have no idea how to do this. You'll have to do some refactoring to accomplish this. Essentially, break apart your method into one that creates a menu for a directory's items and returns the resulting menu. That method will call itself to create menus for subfolders which you would add as subitems to your menu. You would then just call that method on your root directory, Documents in your case, and add the resulting tree of menus wherever you're interested in. third, the code below codes the NSMenuItem to be titled Documents, but it's
NSOutline view contents getting grayed
Hi All, I am writing a coca application in which i use NSOutline view for Navigating between different view like iTunes. So when i am clicking on the ouline view contents, the contents are highlighted in the blue. If i click on any other view other than the ouline view, ouline view content which i had chosen is becoming light gray colour. Is there any way in which i can still retain blue colour in the selected otline view content? Thanks Arun KA ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSOutline view contents getting grayed
That is happening because the outline view is loosing it's it's first responder status. You can refuse to resign the first responder status by overriding - (BOOL)resignFirstResponder and returning NO HTH, Chaitanya On 06-Dec-08, at 4:43 PM, Arun wrote: Hi All, I am writing a coca application in which i use NSOutline view for Navigating between different view like iTunes. So when i am clicking on the ouline view contents, the contents are highlighted in the blue. If i click on any other view other than the ouline view, ouline view content which i had chosen is becoming light gray colour. Is there any way in which i can still retain blue colour in the selected otline view content? Thanks Arun KA ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/chaitanya%40expersis.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSOutline view contents getting grayed
Hi , I tried the technique which you had suggested, it solved the graying problem. But if i use this i will not be able to perform any actions on the other views as outline view is the first responder always. any idea? -Arun On Sat, Dec 6, 2008 at 5:04 PM, chaitanya pandit [EMAIL PROTECTED]wrote: That is happening because the outline view is loosing it's it's first responder status. You can refuse to resign the first responder status by overriding - (BOOL)resignFirstResponder and returning NO HTH, Chaitanya On 06-Dec-08, at 4:43 PM, Arun wrote: Hi All, I am writing a coca application in which i use NSOutline view for Navigating between different view like iTunes. So when i am clicking on the ouline view contents, the contents are highlighted in the blue. If i click on any other view other than the ouline view, ouline view content which i had chosen is becoming light gray colour. Is there any way in which i can still retain blue colour in the selected otline view content? Thanks Arun KA ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/chaitanya%40expersis.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSOutline view contents getting grayed
On 6 Dec 2008, at 10:34 pm, chaitanya pandit wrote: That is happening because the outline view is loosing it's it's first responder status. You can refuse to resign the first responder status by overriding - (BOOL)resignFirstResponder and returning NO Except that is likely to cause the rest of your user interface to stop working in a useful way (i.e. text fields etc can't become key). On 06-Dec-08, at 4:43 PM, Arun wrote: Hi All, I am writing a coca application in which i use NSOutline view for Navigating between different view like iTunes. So when i am clicking on the ouline view contents, the contents are highlighted in the blue. If i click on any other view other than the ouline view, ouline view content which i had chosen is becoming light gray colour. Is there any way in which i can still retain blue colour in the selected otline view content? I handle this by subclassing the outline view and implementing: - (void)highlightSelectionInClipRect:(NSRect) clipRect { [super highlightSelectionInClipRect:clipRect]; NSRange rows = [self rowsInRect:clipRect]; if( NSLocationInRange([self selectedRow], rows)) { NSRect sr = [self rectOfRow:[self selectedRow]]; [[NSColor selectedTextBackgroundColor] set]; [NSBezierPath fillRect:sr]; } } Here I'm just using the selected text colour the user has set in the system prefs, but you can use whatever you want. Also, in 10.5 there were some new methods added that allow you to set a highlighting style which might make this approach unnecessary, but off the top of my head I don't know exactly the details as I'm not at my main computer. hth, Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
MDQuery and searching within application package
My app has a number of document templates stored within the application package. The app adds these document templates to the metadata store itself via mdimport. Spotlight correctly locates and identifies the document UTI. When querying these documents with MDQuery - setSearchScopes: [NSArray arrayWithObjects:appPath, nil] I get zero results. Experimenting with Spotlight and mdfind -onlyin seems to suggest that even if data exists within the store you cannot query the package directly. However, results can be obtained by querying the applications enclosing folder. Is there a way to query the package and its subfolders directly? I have come across the com.apple.package UTI but am not certain if it is of any relevance to this situation. 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 [EMAIL PROTECTED]
Re: NSOutline view contents getting grayed
Hi, Thats correct. But in My application i have a table view in which i need to take some actions. In short i can say that My application should behave like iTunes where in it just slightly changes the color of selected playlist in oulineview but still allows doubl-click and slection highlighting on the table view. any idea? -Arun On Sat, Dec 6, 2008 at 5:39 PM, Graham Cox [EMAIL PROTECTED] wrote: On 6 Dec 2008, at 10:34 pm, chaitanya pandit wrote: That is happening because the outline view is loosing it's it's first responder status. You can refuse to resign the first responder status by overriding - (BOOL)resignFirstResponder and returning NO Except that is likely to cause the rest of your user interface to stop working in a useful way (i.e. text fields etc can't become key). On 06-Dec-08, at 4:43 PM, Arun wrote: Hi All, I am writing a coca application in which i use NSOutline view for Navigating between different view like iTunes. So when i am clicking on the ouline view contents, the contents are highlighted in the blue. If i click on any other view other than the ouline view, ouline view content which i had chosen is becoming light gray colour. Is there any way in which i can still retain blue colour in the selected otline view content? I handle this by subclassing the outline view and implementing: - (void)highlightSelectionInClipRect:(NSRect) clipRect { [super highlightSelectionInClipRect:clipRect]; NSRange rows = [self rowsInRect:clipRect]; if( NSLocationInRange([self selectedRow], rows)) { NSRect sr = [self rectOfRow:[self selectedRow]]; [[NSColor selectedTextBackgroundColor] set]; [NSBezierPath fillRect:sr]; } } Here I'm just using the selected text colour the user has set in the system prefs, but you can use whatever you want. Also, in 10.5 there were some new methods added that allow you to set a highlighting style which might make this approach unnecessary, but off the top of my head I don't know exactly the details as I'm not at my main computer. hth, Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSOutline view contents getting grayed
On 06-Dec-08, at 6:19 PM, Arun wrote: Hi, Thats correct. But in My application i have a table view in which i need to take some actions. In short i can say that My application should behave like iTunes where in it just slightly changes the color of selected playlist in oulineview but still allows doubl-click and slection highlighting on the table view. I think what you'll have to do is use a custom cell for the table view. any idea? -Arun On Sat, Dec 6, 2008 at 5:39 PM, Graham Cox [EMAIL PROTECTED] wrote: On 6 Dec 2008, at 10:34 pm, chaitanya pandit wrote: That is happening because the outline view is loosing it's it's first responder status. You can refuse to resign the first responder status by overriding - (BOOL)resignFirstResponder and returning NO Except that is likely to cause the rest of your user interface to stop working in a useful way (i.e. text fields etc can't become key). On 06-Dec-08, at 4:43 PM, Arun wrote: Hi All, I am writing a coca application in which i use NSOutline view for Navigating between different view like iTunes. So when i am clicking on the ouline view contents, the contents are highlighted in the blue. If i click on any other view other than the ouline view, ouline view content which i had chosen is becoming light gray colour. Is there any way in which i can still retain blue colour in the selected otline view content? I handle this by subclassing the outline view and implementing: - (void)highlightSelectionInClipRect:(NSRect) clipRect { [super highlightSelectionInClipRect:clipRect]; NSRange rows = [self rowsInRect:clipRect]; if( NSLocationInRange([self selectedRow], rows)) { NSRect sr = [self rectOfRow:[self selectedRow]]; [[NSColor selectedTextBackgroundColor] set]; [NSBezierPath fillRect:sr]; } } Here I'm just using the selected text colour the user has set in the system prefs, but you can use whatever you want. Also, in 10.5 there were some new methods added that allow you to set a highlighting style which might make this approach unnecessary, but off the top of my head I don't know exactly the details as I'm not at my main computer. hth, Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Reading in XML with iso-8859-1 encoding?
On Dec 6, 2008, at 4:35 AM, Amy Gibbs wrote: I've got a web based xml file in iso-8859-1 encoding that I'm trying to read into an NSXMLDocument. I've got the following code, but I can't seem to make it work? (I've tried all manner of combinations) //create the url NSString *urlString = [NSString stringWithFormat: @http://www.willowtreecrafts.co.uk/ag/ sesbuddyimport.php]; NSURL *url = [NSURL URLWithString:urlString]; NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30]; //fetch the xml response NSData *urlData; NSURLResponse *response; NSError *error; urlData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:response error:error]; if (!urlData){ NSAlert *alert=[NSAlert alertWithError:error]; [alert runModal]; return; } //parse the xml response [doc release]; [doc setCharacterEncoding:@iso-8859-1]; I'm guessing that doc is initially nil, so the above two lines are doing nothing (messages sent to nil). //NSString *xmlstring = [NSString stringWithContentsOfURL:url usedEncoding:@iso-8859-1 error:error]; doc=[[NSXMLDocument alloc]initWithData:urlData options:0 error:error ]; //doc=[[NSXMLDocument alloc]initWithContentsOfURL:url options:0 error:error]; //doc=[[NSXMLDocument alloc]initWithXMLString:xmlstring options:0 error:error]; I get an error telling me that the input is not in UTF-8 encoding. I know the input isn't UTF-8, but how can I get it to accept the iso-8859-1 file? You can probably simplify this a bit by using stringWithContentsOfURL:encoding:error. Note 'encoding' and not 'usedEncoding'. The former allows you to specify the encoding. In this case, use the constant NSISOLatin1StringEncoding (which is ISO_8859-1). Side note. Some parsers are especially picky about encoding names, so best to always use the constants. The official string for this particular encoding is ISO_8859-1. Some parsers allow aliases or modifications as well (hyphens, lowercase, etc.) Then, feed the string (which is now properly decoded) into a new XML doc for parsing: NSXMLDocument* theXMLDoc = [[NSXMLDocument alloc] initWithXMLString:theString options:myOptions error:myError]; //do work [theXMLDoc release]; ___ Ricky A. Sharp mailto:[EMAIL PROTECTED] 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 [EMAIL PROTECTED]
Re: Reading in XML with iso-8859-1 encoding?
Is this 10.5 only? It doesn't seem to be recognised by xcode 2.5, and it doesn't run on my machine at all. I should have mentioned I'm targeting 10.4 with this. Sorry, On 6 Dec 2008, at 12:58, Ricky Sharp wrote: You can probably simplify this a bit by using stringWithContentsOfURL:encoding:error. Note 'encoding' and not 'usedEncoding'. The former allows you to specify the encoding. In this case, use the constant NSISOLatin1StringEncoding (which is ISO_8859-1). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Reading in XML with iso-8859-1 encoding?
On Dec 6, 2008, at 7:17 AM, Amy Gibbs wrote: Is this 10.5 only? It doesn't seem to be recognised by xcode 2.5, and it doesn't run on my machine at all. I should have mentioned I'm targeting 10.4 with this. stringWithContentsOfURL:encoding:error is in 10.4 and later. Do you have the proper SDK specified (e.g. 10.4 universal?) On 6 Dec 2008, at 12:58, Ricky Sharp wrote: You can probably simplify this a bit by using stringWithContentsOfURL:encoding:error. Note 'encoding' and not 'usedEncoding'. The former allows you to specify the encoding. In this case, use the constant NSISOLatin1StringEncoding (which is ISO_8859-1). ___ Ricky A. Sharp mailto:[EMAIL PROTECTED] 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 [EMAIL PROTECTED]
Re: Reading in XML with iso-8859-1 encoding?
In my project details I've got 10.4 (Universal) selected, I've got xcode set up to do that autocomplete type thing, and it doesn't come up with encoding for NSString initWithContentsoOfURL, it does have encodingOnlyStreamAction? On 6 Dec 2008, at 13:24, Ricky Sharp wrote: On Dec 6, 2008, at 7:17 AM, Amy Gibbs wrote: Is this 10.5 only? It doesn't seem to be recognised by xcode 2.5, and it doesn't run on my machine at all. I should have mentioned I'm targeting 10.4 with this. stringWithContentsOfURL:encoding:error is in 10.4 and later. Do you have the proper SDK specified (e.g. 10.4 universal?) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSOutline view contents getting grayed
Hi What ever suggested by Graham has worked for me. Now i have one more problem where i am unable to turn on the text color to white upon selection in the outline view. Any idea? Thanks Arun KA On Sat, Dec 6, 2008 at 6:28 PM, chaitanya pandit [EMAIL PROTECTED]wrote: On 06-Dec-08, at 6:19 PM, Arun wrote: Hi, Thats correct. But in My application i have a table view in which i need to take some actions. In short i can say that My application should behave like iTunes where in it just slightly changes the color of selected playlist in oulineview but still allows doubl-click and slection highlighting on the table view. I think what you'll have to do is use a custom cell for the table view. any idea? -Arun On Sat, Dec 6, 2008 at 5:39 PM, Graham Cox [EMAIL PROTECTED] wrote: On 6 Dec 2008, at 10:34 pm, chaitanya pandit wrote: That is happening because the outline view is loosing it's it's first responder status. You can refuse to resign the first responder status by overriding - (BOOL)resignFirstResponder and returning NO Except that is likely to cause the rest of your user interface to stop working in a useful way (i.e. text fields etc can't become key). On 06-Dec-08, at 4:43 PM, Arun wrote: Hi All, I am writing a coca application in which i use NSOutline view for Navigating between different view like iTunes. So when i am clicking on the ouline view contents, the contents are highlighted in the blue. If i click on any other view other than the ouline view, ouline view content which i had chosen is becoming light gray colour. Is there any way in which i can still retain blue colour in the selected otline view content? I handle this by subclassing the outline view and implementing: - (void)highlightSelectionInClipRect:(NSRect) clipRect { [super highlightSelectionInClipRect:clipRect]; NSRange rows = [self rowsInRect:clipRect]; if( NSLocationInRange([self selectedRow], rows)) { NSRect sr = [self rectOfRow:[self selectedRow]]; [[NSColor selectedTextBackgroundColor] set]; [NSBezierPath fillRect:sr]; } } Here I'm just using the selected text colour the user has set in the system prefs, but you can use whatever you want. Also, in 10.5 there were some new methods added that allow you to set a highlighting style which might make this approach unnecessary, but off the top of my head I don't know exactly the details as I'm not at my main computer. hth, Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Window moving during drag and drop operation, (newbiew question)
On 6.12.2008, at 12:20, Gustavo Pizano wrote: Hi all, its me again. well Im implementing the drag-n-drop op for my app. in the Soruce view I have different layers, im checking which one of those was clicked and then commence the drag and drop, but the funny part is that ithe main window ts moving. Any clues why is this happening.. thsi is my code Im using -(void)mouseDragged:(NSEvent *)event { NSPoint down = [mouseDownEvent locationInWindow]; NSPoint drag = [event locationInWindow]; float distance = hypot(down.x - drag.x , down.y - drag.y); if(distance 3){ return; } //NSEnumerator * e = [shipsLayers objectEnumerator]; NSPoint auxPoint; auxPoint = [self convertPoint:[mouseDownEvent locationInWindow] fromView:nil]; CGRect r; CALayer * actualLayer = [CALayer layer]; BOOL inRect = NO; int i; for (i =0;i [shipsLayers count]; i++){ actualLayer = [shipsLayers objectAtIndex:i]; r = [actualLayer frame]; if(NSPointInRect(auxPoint,NSRectFromCGRect(r))){ inRect= YES; break; } } if(!inRect) return; //if the drag wasn't made on any of the layers containning ships //Create the image that will be dragged NSSize s; s = NSSizeFromCGSize(actualLayer.frame.size); //Create a rect in which the image will be drawn NSRect imageBounds; imageBounds.origin=NSZeroPoint; imageBounds.size = s; //try out CGImageRef cgImage = (CGImageRef)actualLayer.contents; NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage]; // Create an NSImage and add the bitmap rep to it... NSImage *image = [[NSImage alloc] init]; [image addRepresentation:bitmapRep]; [bitmapRep release]; // to here //draw the image [image lockFocus]; NSRect drawingRect = imageBounds; [image drawInRect:drawingRect fromRect:imageBounds operation:NSCompositeSourceOver fraction:0.8]; [image unlockFocus]; //get the location of the mouse auxPoint.x = auxPoint.x - s.width/2; auxPoint.y = auxPoint.y - s.height/2; //Get the Pasteboard NSPasteboard * pb = [NSPasteboard pasteboardWithName:NSDragPboard]; //put the image on the pb, first delcare the types then copy the image into the pb [pb declareTypes:[NSArray arrayWithObjects:NSTIFFPboardType,NSPostScriptPboardType,nil] owner:self]; //put the image into the pasteboard [pb setData:[NSKeyedArchiver archivedDataWithRootObject:image] forType:NSTIFFPboardType]; //start the drag [self dragImage:image at:auxPoint offset:NSMakeSize(0, 0) event:mouseDownEvent pasteboard:pb source:self slideBack:YES]; [image release]; } Thanks a lot guys for your help Gustavo ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Document package
Hi, I'm trying to make document package using NSFileWrapper. I could contain a regular file in the directory (document package), but the directory can't change its appearance, this is, it still looks a folder, not the icon I have specified in my info.plist. I have also set LSTypeIsPackage of the document type to TRUE. I did like the following: - (NSFileWrapper *)fileWrapperOfType:(NSString *)typeName error:(NSError **)outError { NSFileWrapper * result = [[NSFileWrapper alloc] initDirectoryWithFileWrappers:nil]; NSData* data = [self dataOfType:typeName error:outError]; [result addRegularFileWithContents:data preferredFilename:@myData]; return result; } Would you tell me what I'm missing? Any suggestions would be appreciated. Thanks, Norio ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Questions about [NSApplication run]
What about spawning a secondary thread which uses select (or kqueue, which is pretty easy to use BTW) to block waiting for events, without a timeout. When select (or kqueue) returns an event(s), then use: [yourAppDelegateOrControllerOrWhatever performSelectorOnMainThread: @selector(handleFactorEvent:) withObject: yourCustomEventDescriptorClass waitUntilDone: NO] That's the simple version. In my own code, the bg thread actually invokes in the bg thread a method on my app delegate that creates the event instance and puts the event on a queue (std::vectormythingy with appropriate locking) before calling performSelectorOnMainThread which will pull events out of the queue until there are no more. And... I don't rememeber why ;-) -- Scott Ribe [EMAIL PROTECTED] http://www.killerbytes.com/ (303) 722-0567 voice ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
JSON Framework
Hi, I hope someone can help me. I thought I was going to be able to use the JSON Framework from google code (http://code.google.com/p/json-framework/ ) but it won't build under the 10.4 SDK. I get errors on the build, mostly stuff that changed under 10.5. Does anyone know of a JSON framework for Cocoa that will work under 10.4 also and is freely available? I guess I may have to change the code for the JSON framework to fix the errors if not. Thanks in advance. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Custom Window Resize Image
Thanks, I'm going to share what I did, just incase someone else is wanting to know how to do this. - (void)mouseDown:(NSEvent *)theEvent { // Resize if mouse is in the growbox isResizing = NSPointInRect([self convertPoint:[theEvent locationInWindow] fromView:nil], growRect); } - (void)mouseDragged:(NSEvent *)theEvent { // Get window frame to get the current size and position NSRect frameR = [[self window] frame]; int dX = [theEvent deltaX]; int dY = [theEvent deltaY]; // If resizing than resize if (isResizing) { // Limit window size to 90 so the user doesn't bring it down to 0 if (frameR.size.width 90 dX 1) dX = 0; if (frameR.size.height 90 dY 1) dY = 0; // Resize the window [[self window] setFrame:NSMakeRect(frameR.origin.x, frameR.origin.y - dY, frameR.size.width + dX, frameR.size.height + dY) display:YES]; } else { // Move the window if it isn't resizing [[self window] setFrameOrigin:NSMakePoint(frameR.origin.x + dX, frameR.origin.y - dY)]; } } - (void)mouseUp:(NSEvent *)theEvent { // Minimize window if mouse is in minimze button if (NSPointInRect([self convertPoint:[theEvent locationInWindow] fromView:nil], minimizeRect)) { [[self window] miniaturize:self]; } // Set that were not resizing now that the user mouse isn't clicking isResizing = NO; } On Dec 5, 2008, at 5:39 PM, Ron Fleckner wrote: Hi Mr. Gecko, I made a borderless window which I wanted to be resizable, so I put a copy of resize.png in my app's resources. During startup, I add it to the bottom right corner of my window, then by implementing mouse down and mouse dragged, implement my own window resizing mechanism. It's a little bit of work but the end result works fine. In - mouseDown, I check if the event is in the grow box region, and set a BOOL isResizing ivar. In -mouseDragged I check isResizing to see if I need to resize the window or just let it be moved around. Ron On 05/12/2008, at 3:28 PM, Mr. Gecko wrote: Ok so I've done some looking around more in the documents, would it be possible to make a button that has a picture of the grow box and than have it send an action when it's dragged using NSLeftMouseDraggedMask. On Dec 4, 2008, at 8:47 PM, Sean McBride wrote: Ron Fleckner ([EMAIL PROTECTED]) on 2008-12-04 12:52 AM said: Hello, I'm writing a custom window for my application, but I can't figure out how to make a custom resize image... Any help? Thanks, Mr. Gecko Unless you actually want a 'custom' resize image, you can use the real one found at /System/Library/WidgetResources/resize.png If you wanted to draw the standard grow box, you could use HIThemeDrawGrowBox(). Relying on that file being at that location is fragile. But... Mr. Gecko ([EMAIL PROTECTED]) on 2008-12-04 1:01 PM said: I'm not needing to know how to draw it, I'm needing to know how to make it functional. so if someone clicks and drags it would resize the window. That's not at all what you asked. :) Perhaps you could clarify? To change a window's size you can use the setFrame... methods. Sean ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSOutline view contents getting grayed
On Dec 6, 2008, at 4:13 AM, Arun wrote: Hi All, I am writing a coca application in which i use NSOutline view for Navigating between different view like iTunes. So when i am clicking on the ouline view contents, the contents are highlighted in the blue. If i click on any other view other than the ouline view, ouline view content which i had chosen is becoming light gray colour. Is there any way in which i can still retain blue colour in the selected otline view content? Thanks Arun KA If you are developing for 10.5, you can change the outline view to a Source List style with setSelectionHighlightStyle: or in IB by changing the Highlight popup from Regular to Source List. That will set it up to duplicate the iTunes look. --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 [EMAIL PROTECTED]
cocoa class diagram
I was wondering whether there is a Cocoa class diagram poster to print. Thanx ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Not getting KeyDown events (and other peculiar things)
Hello, I'm resending this because it didn't seem to get through to the list: On Fri, Dec 5, 2008 at 8:47 AM, Shayne Wissler [EMAIL PROTECTED] wrote: I'm writing something like a game engine using NSOpenGLView and am getting some odd behaviors (I am new to Cocoa): 1. Clicking on the title bar of my application does not activate my application, but clicking inside my window does. I can move the window around on the screen, but unlike all the other applications I must click inside the window to make it the main window. 2. The resize handle that's normally on the bottom right corner is not shown, but it is apparently there because when I click in that area and drag the window resizes. [window showsResizeIndicator] returns true even though the indicator isn't shown. 3. The worst problem is that I'm not getting key events even though I have defined these methods: - (BOOL)acceptsFirstResponder { return YES; } - (BOOL)becomeFirstResponder { return YES; } - (BOOL)canBecomeKeyView { return YES; } - (void)keyDown:(NSEvent*)theEvent { ... } - (void)keyUp:(NSEvent*)theEvent { ... } I am getting mouse events just fine, but when I click on a key, the keypress goes to the previously selected application, or if there is none, I just hear a beep. I have printed out the status [[self window] isKeyWindow] on a mouseDown event and it is indeed true, making this seem even more bizarre to me. Note: I am not using nib files so awakeFromNib does not get called in my application. Any helpful comments would be appreciated! Shayne Wissler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: What are the limitations of Dot Syntax?
On Dec 5, 2008, at 10:06 PM, Bill Bumgarner wrote: Not really. 'name' is still something that is an accessor type thing, regardless of whether it is derived or declared via @property() dot abuse refers to expressions like: foo.retain; bar.lockFocusIfCanDraw; That is, expressions where you aren't really asking the object to retrieve some value, but are more or less telling the object to do something and return a result. And, yes, there are grey areas. So would something which is clearly not a property, but still returns an object, such as: myObj = mySet.anyObject; or: enumerator = myArray.objectEnumerator; be considered kosher? Charles ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: What are the limitations of Dot Syntax?
Namaste! I'm going to add my two cents here (despite being a noob). I like the dot syntax. Why? (and before I go any further, I realize this is not a Windows forum, and also realize this is a very general set of statements and quite open to debate) Because, in the Windows world at least, the dot allowed you to refer to *members* of an object. What are members? They are attributes of the object. In programming simplicity, they are: properties or methods. So, what's wrong with the dot syntax? Nada in my book. A fuller implementation of the dot syntax is more desireable in my book. From whence I came, it sure made code very much more readable and quicker to write. That being said, I don't have an issue with the way things are, nor do I really care much how they evolve, provided the evolution is for the better. The bottom line, as long as your code is readable, digestible, consistent, and clearly commented in tricky spots for those who come after you (and yourself later down the road too), it really doesn't matter, does it? Peace, Love, and Light, /s/ Jon C. Munson II Quoting Charles Srstka [EMAIL PROTECTED]: On Dec 5, 2008, at 10:06 PM, Bill Bumgarner wrote: Not really. 'name' is still something that is an accessor type thing, regardless of whether it is derived or declared via @property() dot abuse refers to expressions like: foo.retain; bar.lockFocusIfCanDraw; That is, expressions where you aren't really asking the object to retrieve some value, but are more or less telling the object to do something and return a result. And, yes, there are grey areas. So would something which is clearly not a property, but still returns an object, such as: myObj = mySet.anyObject; or: enumerator = myArray.objectEnumerator; be considered kosher? Charles ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/jmunson%40his.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: JSON Framework
On Dec 6, 2008, at 11:51 AM, development2 wrote: Hi, I hope someone can help me. I thought I was going to be able to use the JSON Framework from google code (http://code.google.com/p/json-framework/ ) but it won't build under the 10.4 SDK. I get errors on the build, mostly stuff that changed under 10.5. Does anyone know of a JSON framework for Cocoa that will work under 10.4 also and is freely available? I guess I may have to change the code for the JSON framework to fix the errors if not. I believe that BSJSONAddition's will build under 10.4. The SVN repo is located at http://blakeseely.com/svn/public/BSJSONAdditions/trunk/ Bill ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: What are the limitations of Dot Syntax?
On Dec 6, 2008, at 11:15 AM, Charles Srstka wrote: So would something which is clearly not a property, but still returns an object, such as: myObj = mySet.anyObject; or: enumerator = myArray.objectEnumerator; be considered kosher? If you can write that and sleep well at night, then sure... go for it. Seriously -- there isn't a hard defined line for this. Personally, I initially found code like the above distasteful when I was first writing code with the dot syntax. At first, my thinking was much more hardline if it is a setter/getter, use dot. Otherwise, do not.. Over time, I have tended to write code like the above more and more often. -anyObject and -objectEnumerator don't really act on the target, they simply retrieve something from the target. And that is definitely in line with the thinking behind the dot syntax. 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 [EMAIL PROTECTED]
Cleanup inside a failed init method
Hi I'm writing my own socket class using a bunch of BSD functions and am a little unclear on exactly what I should be doing to insure everything is cleaned up if any of the low level functions fail. If I return nil from my init, does the system call my dealloc method to allow proper cleanup? Or do I have to do the cleanup before returning? Here's what I have so far - (id) initWithHost:(NSString *) inHost port:(int) inPort error:(NSString **) inError { id result = nil; self = [super init]; if (self) { host= [inHost copy]; port= inPort; // if any of the following fails, I want to cleanup // completely before returning // am I doing that correctly? // host and error are the only Cocoa objects // I'm holding on to. The other stuff is from the BSD functions if ([self getAddress] [self createSocket] [self connect] [self updateStream]) { result = self; } else { freeaddrinfo(addressInfo); close(socketFD); *inError= [error copy]; [error release]; [host release]; } } return result; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Cleanup inside a failed init method
- Original Message From: Ken Tozier [EMAIL PROTECTED] To: Cocoa Developers cocoa-dev@lists.apple.com Sent: Saturday, December 6, 2008 1:07:00 PM Subject: Cleanup inside a failed init method Hi I'm writing my own socket class using a bunch of BSD functions and am a little unclear on exactly what I should be doing to insure everything is cleaned up if any of the low level functions fail. If I return nil from my init, does the system call my dealloc method to allow proper cleanup? Or do I have to do the cleanup before returning? The system will only call dealloc if the object is released. Happily, the object should be released anyway if you plan to return nil since otherwise you'll leak a half-initialized object every time the method fails. So you should release self and return nil. Cheers, Chuck ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Cleanup inside a failed init method
On Dec 6, 2008, at 1:36 PM, Charles Steinman wrote: From: Ken Tozier [EMAIL PROTECTED] To: Cocoa Developers cocoa-dev@lists.apple.com I'm writing my own socket class using a bunch of BSD functions and am a little unclear on exactly what I should be doing to insure everything is cleaned up if any of the low level functions fail. If I return nil from my init, does the system call my dealloc method to allow proper cleanup? Or do I have to do the cleanup before returning? The system will only call dealloc if the object is released. Happily, the object should be released anyway if you plan to return nil since otherwise you'll leak a half-initialized object every time the method fails. So you should release self and return nil. I used the [self release] pattern for a long time, but this thread indicates that you should clean up in the initializer, then call [super dealloc] directly: http://lists.apple.com/archives/objc-language/2008//Sep/msg00133.html -- Adam smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Cleanup inside a failed init method
Should initWithHost be doing anything other than caching the host info? Other methods should do the connection/verification etc, no? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Vertically centering NSTextView
Hi, I've written a text container to fit text inside of an oval shape (phew), and now I'd like to center the text vertically within the text view. What's the best way to approach this? NSLayoutManager is a jungle, and I'm not sure it's the right place to look. Thanks! Tomas Franzén Lighthead Software http://www.lightheadsw.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 [EMAIL PROTECTED]
Re: Cleanup inside a failed init method
It's a matter of preference I guess. In practice, I can't think of any reason to connect to a server unless you intend to talk to it, so I just wrapped up all the ugliness into a nice simple interface. Creating one of my KClientSockets, connects to the host and retrieves any handshake data automatically. For example: To connect to MySQL on the local machine KClientSocket *socket = [KClientSocket connectToHost: @localhost port: 3306]; KSocketStream *handshake = [socket stream]; Done On Dec 6, 2008, at 4:58 PM, Steven W Riggins wrote: Should initWithHost be doing anything other than caching the host info? Other methods should do the connection/verification etc, no? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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/kentozier%40comcast.net This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Cleanup inside a failed init method
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_4_section_4.html#//apple_ref/doc/uid/TP30001163-CH22-SW13 mmalc ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Cleanup inside a failed init method
Hi Chuck, On Dec 6, 2008, at 22:36, Charles Steinman wrote: The system will only call dealloc if the object is released. Happily, the object should be released anyway if you plan to return nil since otherwise you'll leak a half-initialized object every time the method fails. So you should release self and return nil. I'm not sure about that. Take a look at this example: // init only modifies an already allocated buffer. // ObjC and the O/S does not know what you are going to name your 'init' method: - (id)initIthMyParameters:(int)aParameter { self = [super init]; if(self) // only if super returns a valid buffer { parameter = aParameter; } return(self); } ob = [[MyObject alloc] initWithMyParameters:3]; The result of [MyObject alloc] is passed directly to initWithMyParameters:. If alloc fails, it sends NULL as object to init. [NULL init] returns NULL, no matter which object it is, so does [NULL sniff_sniff]. -However, if +alloc succeeds, you have a buffer, it's passed directly to initWithMyParameters:. You're not guaranteed that you will get the same buffer that [MyObject alloc] returns, because -init* will be able to deallocate it and return a different (maybe even larger) buffer instead, and perhaps in a different memory zone. Who/what is supposed to deallocate the allocated buffer between the [MyObject alloc] and [myObject init] ? (How would the 'system' know that the object is to be deallocated?) The only reason would be that the line... self=NULL; ...should automatically deallocate the object, and I've never heard that it did. The general rule is: Whatever mess you create (inside your method), you have to cleanup yourself, noone else is doing it for you. -But if you return NULL from -init, you *must* deallocate self first, or you will leak memory. Love, Jens ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: cocoa class diagram
On Sat, Dec 6, 2008 at 12:42 PM, macdev [EMAIL PROTECTED] wrote: I was wondering whether there is a Cocoa class diagram poster to print. Check out CocoaNav: http://inexdo.com/CocoaNav --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Big picture relationships between NSConnection, NSInputStream, NSOutputStream etc
On 04 Dec 08, at 16:39, Ken Tozier wrote: snip... I tried it out and got the following printout to the console inputStream: NSCFInputStream: 0x13d170, outputStream: NSCFOutputStream: 0x13d1e0 connection: MySQLConnection: 0x824800 Entered: stream:handleEvent: with sender: NSCFInputStream: 0x13d170 NSStreamEventErrorOccurred: Error Domain=NSPOSIXErrorDomain Code=61 Operation could not be completed. Connection refused Entered: stream:handleEvent: with sender: NSCFOutputStream: 0x13d1e0 Which seems to make sense because MySQL requires a handshake and NSSocket doesn't know how to respond to that handshake. To perform the handshake, it seems I need to descend into BSD sockets. This is incorrect. A connection refused error in this context means that you're either trying to connect to a host/port which is not configured to accept a connection, or the host is behind a firewall which blocks incoming connections. In this case, it's probably the former. But what you're probably running into here is simply the fact that MySQL doesn't accept TCP connections at all by default - instead, it uses a UNIX domain socket in either /var/tmp/mysql.sock or /tmp/ mysql.sock. More to the point, though, why are you trying to reimplement the MySQL client library? You haven't even gotten to the wire protocol yet, which I guarantee is going to pose you even more problems than just connecting to the server. If you're just concerned about having to include the library, you can link statically against the libmysqlclient library to avoid having to drag the shared library around with you. (Note, however, that libmysqlclient is licensed under the GPL, so you'll need to talk to Sun if you want to use it in non- free software.) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: cocoa class diagram
That's one of the coolest interfaces I've seen yet (or maybe I haven't seen much). How'd he/she/they do that??? Thanks for sharing! Peace, Love, and Light, /s/ Jon C. Munson II Quoting Kyle Sluder [EMAIL PROTECTED]: On Sat, Dec 6, 2008 at 12:42 PM, macdev [EMAIL PROTECTED] wrote: I was wondering whether there is a Cocoa class diagram poster to print. Check out CocoaNav: http://inexdo.com/CocoaNav --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/jmunson%40his.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Various syntax errors and ICA kit
Namaste! OK, after much beating of head against wall, I found the issue. 'Twas the way the #import statements were set up. Once I moved the Cocoa Carbon imports to the header file that cleared up quite a bit of my issues. Also, I believe I had some of my own ignorance tossed in as well. Made one heck of a salad... Peace, Love, and Light, /s/ Jon C. Munson II Quoting [EMAIL PROTECTED]: Namaste! Also, if I take out the #import statement from the .m file, I get a compiler warning about a forward class. I don't know if that means anything truly important or not (but that was when i figured I forgot the #import part). If I can ignore that, then I may get my app to compile and run properly... Peace, Love, and Light, /s/ Jon C. Munson II Quoting [EMAIL PROTECTED]: Namaste! And so the fun ensues... I'm working with the (slightly, deprecated in 10.5) older ICA (as the newer doesn't work). I've brought over the code base from the SampleScanner application in the Carbon-ImageCapture-Examples folder and applied it to mine own form. Before I attempted to integrate it fully into my app (meaning, actually call it from the form that needs to call it), the nib controller files compiled just peachy (no errors, just deprecation warnings mostly). So, I added it to my calling window (instantiated the class, #imported the header, and so on) and created a method a button could trigger. Now, however, my application won't compile. It complains of syntax errors in the ICA form's header file: Syntax error before ICAObject Syntax error before ICARegisterEventNotificationPB Syntax error before ICAScannerStartPB Fatal error: method definition not in @implementation context If I take the header import out of the .m file for the calling window, and comment out the calls to the ICA window, the app compiles fine and executes ('course, I can't load the ICA window :( ). My ICA window is identical (with the exception of an icon image at this point) to the SampleScanner window. The .h .m controller files are also identical (except for log, which I removed as I don't need/want that part). Anyone got a clue on this? I almost have this hooked in...so close... Thanks! 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/jmunson%40his.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/jmunson%40his.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: MTOM?
http://wso2.org/ They've implemented a bunch of web services frameworks that can do MTOM in various languages. I've been trying to get the PHP one to build on OSX but have been wrestling with build issues. They don't see very Mac friendly, just Windows and Linux. But you can try. It would be great if Cocoaists with build script skillz would help these people embrace the mac. On Dec 5, 2008, at 11:34 AM, David LeBer wrote: On 5-Dec-08, at 12:16 PM, David LeBer wrote: Hello all, I have a client asking if I can accept binary data via MTOM in their xml responses. To clarify: I wrote a Cocoa app for a client which talks to their webservice. The client now wants to be able to stream large chunks of binary data vended with MTOM. I started to read through the SOAP spec, but my eyes started to bleed. I thought maybe someone else had tackled this nut already. It looks like MTOM is part of the SOAP spec: http://www.w3.org/TR/soap12-mtom/ I have no idea whether this is possible, any suggestions or ideas where to start? ;david -- David LeBer Codeferous Software 'co-def-er-ous' adj. Literally 'code-bearing' site: http://codeferous.com blog: http://davidleber.net profile:http://www.linkedin.com/in/davidleber twitter:http://twitter.com/rebeld -- Toronto Area Cocoa / WebObjects developers group: http://tacow.org ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/tblanchard%40mac.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Big picture relationships between NSConnection, NSInputStream, NSOutputStream etc
On Dec 6, 2008, at 6:45 PM, Andrew Farmer wrote: This is incorrect. A connection refused error in this context means that you're either trying to connect to a host/port which is not configured to accept a connection, or the host is behind a firewall which blocks incoming connections. In this case, it's probably the former. But what you're probably running into here is simply the fact that MySQL doesn't accept TCP connections at all by default - instead, it uses a UNIX domain socket in either /var/tmp/ mysql.sock or /tmp/mysql.sock. The host and client are both on my laptop so I don't think the config/ firewall stuff applies. I got my custom socket class working and was able to connect, at least up to receiving the handshake packet, using TCP. Not sure what Apple is doing in the guts of NSSocketPort, but my class is able to connect and fetch the handshake. When I try the same thing with NSSocketPort's file descriptor, no go. More to the point, though, why are you trying to reimplement the MySQL client library? You haven't even gotten to the wire protocol yet, which I guarantee is going to pose you even more problems than just connecting to the server. If you're just concerned about having to include the library, you can link statically against the libmysqlclient library to avoid having to drag the shared library around with you. (Note, however, that libmysqlclient is licensed under the GPL, so you'll need to talk to Sun if you want to use it in non-free software.) I love a challenge :) It's an interesting problem and I'm learning how to use sockets. I wouldn't have even thought of bypassing the library, but I stumbled across this really cool flash library that connects to MySQL completely via sockets (http://asql.mooska.pl/release/srcview/) and thought it would be cool to do something like that in Cocoa. The MySQL protocol isn't all that difficult. I found a good resource here (http://forge.mysql.com/wiki/ MySQL_Internals_ClientServer_Protocol) The trickiest part seems to be scrambling the user password with the seed MySQL sends in the handshake. I already wrote a nice, simple packet parser to handle the different types of MySQL messages and am working my way through the password stuff. What I'm writing will be installed on about 50 to 100 machines and I have no interest in installing the client lib on all of them. I actually got some code working with the client lib but it broke as soon as it was installed on a different architecture (PowerPC) and OS version (10.4 vs 10.5) These four combinations of OS and processors are a given and I can't do anything about that. Each configuration requires a client lib specifically compiled for it and I don't want to support 4 different versions of my app or the support calls when they do a clean install or an upgrade and suddenly my app stops working. With my own sockets, I'll only ever have to worry about MySQL protocol changes which are much less frequent than MySQL updates. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Reading in XML with iso-8859-1 encoding?
On Sat, Dec 6, 2008 at 8:49 AM, Amy Gibbs [EMAIL PROTECTED] wrote: In my project details I've got 10.4 (Universal) selected, I've got xcode set up to do that autocomplete type thing, and it doesn't come up with encoding for NSString initWithContentsoOfURL, it does have encodingOnlyStreamAction? Xcode's code completion is, to put it mildly, poor. If it doesn't find a particular method that should be there, just type it out longhand. If the compiler then complains about not finding it, then you might have an actual problem. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Cleanup inside a failed init method
On Sat, Dec 6, 2008 at 4:53 PM, Adam R. Maxwell [EMAIL PROTECTED] wrote: I used the [self release] pattern for a long time, but this thread indicates that you should clean up in the initializer, then call [super dealloc] directly: http://lists.apple.com/archives/objc-language/2008//Sep/msg00133.html Wouldn't this fail horribly if your superclass had done something unusual but perfectly legal such as [[self retain] autorelease]? Forcing your subclasses to implement -dealloc methods which can withstand being invoked on an uninitialized object (which, recall, is not terribly hard since its instance variables will be zero-filled) seems like a much better way to go. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Cleanup inside a failed init method
- Original Message From: Jens Bauer [EMAIL PROTECTED] Subject: Re: Cleanup inside a failed init method On Dec 6, 2008, at 22:36, Charles Steinman wrote: The system will only call dealloc if the object is released. Happily, the object should be released anyway if you plan to return nil since otherwise you'll leak a half-initialized object every time the method fails. So you should release self and return nil. I'm not sure about that. Take a look at this example: // init only modifies an already allocated buffer. // ObjC and the O/S does not know what you are going to name your 'init' method: - (id)initIthMyParameters:(int)aParameter { self = [super init]; if(self) // only if super returns a valid buffer { parameter = aParameter; } return(self); } ob = [[MyObject alloc] initWithMyParameters:3]; The result of [MyObject alloc] is passed directly to initWithMyParameters:. If alloc fails, it sends NULL as object to init. [NULL init] returns NULL, no matter which object it is, so does [NULL sniff_sniff]. -However, if +alloc succeeds, you have a buffer, it's passed directly to initWithMyParameters:. You're not guaranteed that you will get the same buffer that [MyObject alloc] returns, because -init* will be able to deallocate it and return a different (maybe even larger) buffer instead, and perhaps in a different memory zone. Who/what is supposed to deallocate the allocated buffer between the [MyObject alloc] and [myObject init] ? (How would the 'system' know that the object is to be deallocated?) The only reason would be that the line... self=NULL; ...should automatically deallocate the object, and I've never heard that it did. I don't know why you think the object would be dealloced between alloc and init. If the if(self) conditional evaluates to nil, that's because [super init] returned nil. Cheers, Chuck ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
NSPredicateEditor and date comparisons
Hi all, In my application, users have the option of comparing to a date in an NSPredicateEditor. For the NSDates it is comparing against, only the date is important; time doesn't matter. The interesting thing I found about NSPredicateEditor is the NSTimeInterval it compares my NSDates to has the time set to 13:41:40. That means my NSDates with the default 12:00:00 time don't match an is predicate. It's not a big deal because I can just change my NSDate's time to 13:41:40 to fix the problem. But what I'm wondering is if this is guaranteed to always be true. I couldn't find it anywhere in the documentation. Thanks, Josh ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
XCode 3.1.1 Cocoa App template project leaking memory
Hello all, it turns out that my application has been leaking a small amount of memory shortly after launching. I looked at the code and there was nothing obviously wrong, and yet Instruments (well, Leaks) tells me that it leaks. I then commented out all the code in all the awakeFromNib methods and in applicationDidFinishLaunching:. These are the only entry points in my app and, yet, Instruments still reports the same leak. On a hunch, I decided to create a new project and run Leaks on it. I just chose a new Cocoa Application project, built it with no changes of any kind, then ran it under Leaks, and it leaks the same amount of memory as my app, and the same objects are being leaked: 144 bytes of NSPathStore2. Just thought I'd pass this along for others to comment on and, perhaps, try on their own computers. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Array Controller Add method question
Thanks for the help ... I'm using an Array Controller's Add method wired to a button to enable text data entries into a table. How do I set the table to activate it's top row when pressing the Add button in preparation for input? At this point if the table contains many rows of data and the user clicks the Add button the table's lowest row activates. The user is forced to scroll down to the very bottom of the table prior to entry Thanks again. vince ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Array Controller Add method question
You might try something like: int row = [a indexOfObjectIdenticalTo:p]; [tableView editColumn:0 row:row withEvent:nil select:YES]; a = your array controller/arrary p = object added This sample from Hillegass' book, Cocoa Programming for Mac OS X Third Edition. Good Luck! Peace, Love, and Light, /s/ Jon C. Munson II Quoting vince [EMAIL PROTECTED]: Thanks for the help ... I'm using an Array Controller's Add method wired to a button to enable text data entries into a table. How do I set the table to activate it's top row when pressing the Add button in preparation for input? At this point if the table contains many rows of data and the user clicks the Add button the table's lowest row activates. The user is forced to scroll down to the very bottom of the table prior to entry Thanks again. vince ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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/jmunson%40his.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
NSImageView gets stuck
Hi, All: I have an NSImageView (in a variable called ball) that I am trying to move programatically across the screen, and when it hits a wall, reposition it in the center. I've set up an NSTimer, and in the timerFireMethod have this: NSRect ballFrame = [ball frame]; ballFrame.origin.x+=ballDeltaX; // move the ball ballFrame.origin.y+=ballDeltaY; works just fine, the ball merrily moves across the NSView. However, when I hit the wall, and do the following: [myController victoryGoesTo:'R']; [timer invalidate]; [self placeBallInCenter]; the placeBallInCenter method fails: -(void)placeBallInCenter{ [ball setFrameOrigin:NSMakePoint(125,125)]; NSLog(@ball frame: %@,NSStringFromRect([ball frame])); } The ball's origin displays correctly in the console as (125,125), but the ball is stuck on the right hand side of the screen, at around 400. I'm using the same technique in placeBallInCenter as I did in my timerFireMethod, so I am perplexed. Thanks for any enlightenment, Michael ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Array Controller Add method question
Yes, you do. Quoting vince [EMAIL PROTECTED]: Thanks. I'm using a Core Data model with Bindings. So there's no code in my class. I simply wired my Add object button to the the Array Controller's (Add) action to insert data into the table. Do I need to implement the Add method manually and customize there? thanks again. vince. On Sat, Dec 6, 2008 at 10:15 PM, [EMAIL PROTECTED] wrote: You might try something like: int row = [a indexOfObjectIdenticalTo:p]; [tableView editColumn:0 row:row withEvent:nil select:YES]; a = your array controller/arrary p = object added This sample from Hillegass' book, Cocoa Programming for Mac OS X Third Edition. Good Luck! Peace, Love, and Light, /s/ Jon C. Munson II Quoting vince [EMAIL PROTECTED]: Thanks for the help ... I'm using an Array Controller's Add method wired to a button to enable text data entries into a table. How do I set the table to activate it's top row when pressing the Add button in preparation for input? At this point if the table contains many rows of data and the user clicks the Add button the table's lowest row activates. The user is forced to scroll down to the very bottom of the table prior to entry Thanks again. vince ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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/jmunson%40his.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/valbino48%40gmail.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSImageView gets stuck
Shot in the dark here... I noticed you are using ballFrame in your timer event, but not in your reset event. Is that your issue? Quoting Michael Rogers [EMAIL PROTECTED]: Hi, All: I have an NSImageView (in a variable called ball) that I am trying to move programatically across the screen, and when it hits a wall, reposition it in the center. I've set up an NSTimer, and in the timerFireMethod have this: NSRect ballFrame = [ball frame]; ballFrame.origin.x+=ballDeltaX; // move the ball ballFrame.origin.y+=ballDeltaY; works just fine, the ball merrily moves across the NSView. However, when I hit the wall, and do the following: [myController victoryGoesTo:'R']; [timer invalidate]; [self placeBallInCenter]; the placeBallInCenter method fails: -(void)placeBallInCenter{ [ball setFrameOrigin:NSMakePoint(125,125)]; NSLog(@ball frame: %@,NSStringFromRect([ball frame])); } The ball's origin displays correctly in the console as (125,125), but the ball is stuck on the right hand side of the screen, at around 400. I'm using the same technique in placeBallInCenter as I did in my timerFireMethod, so I am perplexed. Thanks for any enlightenment, Michael ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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/jmunson%40his.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Array Controller Add method question
On Dec 6, 2008, at 7:15 PM, [EMAIL PROTECTED] wrote: I'm using an Array Controller's Add method wired to a button to enable text data entries into a table. How do I set the table to activate it's top row when pressing the Add button in preparation for input? At this point if the table contains many rows of data and the user clicks the Add button the table's lowest row activates. The user is forced to scroll down to the very bottom of the table prior to entry int row = [a indexOfObjectIdenticalTo:p]; [tableView editColumn:0 row:row withEvent:nil select:YES]; a = your array controller/arrary p = object added The OP asked for the item to be added at the top, so that doesn't help... You need to make sure you insert the new object at the right place in the array controller's arranged objects. One approach is to implement a new action method in your document/ application controller: - (IBAction)newAtTop:sender { id newObject = [arrayController newObject]; [arrayController insertObject:newObject atArrangedObjectIndex:0]; [tableView editColumn:0 row:0 withEvent:nil select:YES]; [newObject release]; } mmalc ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSImageView gets stuck
On 6 Dec, 2008, at 9:52 PM, [EMAIL PROTECTED] wrote: Shot in the dark here... I noticed you are using ballFrame in your timer event, but not in your reset event. Is that your issue? That's a good idea, but I don't believe so: when I replaced my [ball setFrameOrigin:NSMakePoint(125,125)]; line with these: NSRect ballFrame = [ball frame]; ballFrame.origin.x=125; // move the ball ballFrame.origin.y=125; [ball setFrame:ballFrame]; I have the same outcome: the ball stays stuck. Thanks for your reply, Jon. Michael ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSImageView gets stuck
Hi Michael, it's not clear from your code or your message, but could it be that your timer method calls setNeedsDisplay: YES on the appropriate view, but the placeBallInCenter method does not? I've recently made that very mistake and scratched my head for quite a while before I noticed the missing call. Hope this helps. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
File Sharing Within App
Hey, Is there an easy way to embed a file-sharing server into a Cocoa application? Right now, I have a client-server setup that communicates via distributed objects (with Bonjour for discovery). I would like the client to be able to download files from the server, but I don't want to write my own file sharing protocol. Perhaps there is an ftp server I can embed into my server? My purpose in embedding the file sharing server into my application would be to save setup time. It seems the alternative would be instructions for enabling AFP, putting all of the support files into the right directory, then inputting the access information (path, username, password) into the server so the clients can access it. This is an in-house application, so that is all possible, but definitely not preferred. The way I envision my application working, the first time the server opens it would prompt for the directory with all of the supporting files. It would then vend this folder (read-only access) via FTP or a similar protocol. Simple and easy! Are there any libraries / frameworks you would recommend? Thank You, Bridger Maxwell ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]