Re: Outrunning the Garbage Collector
Hi Jeffrey, I have a multithreaded application with several NSOperationQueues and it appears as if under heavy load conditions I'm overwhelming the garbage collector so-to-speak. From what you describe, it looks like your analysis is spot on. I essentially have three queues which can be processing different types of operations simultaneously. - If I load up *one* queue with a bunch of operations and let it run, I find that memory is clean up very nicely. After each operation finishes it gets cleaned up by the collector appropriately. - If I load up all three queues simultaneously (a not uncommon user scenario for this application), then I find that rarely do any of the operations get cleaned up. Things generally start out alright, but then get jugged up and very quickly the application can run out of memory. You essentially have to throttle the mutator(s) so they don't outrun the collector. The collector has a tough time keeping up with one full-throttle mutator, three (assuming you've got a thread servicing each queue) is fairly hopeless. Another option *may* be to recode your app to produce significantly less garbage for the collector to clean up. The GC release notes suggest that it's possible to outrun the collector, http://developer.apple.com/releasenotes/Cocoa/GCReleaseNotes/ index.html It is, as you've noticed. Marcel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Garbage collector related crash
I've got an object that holds onto a CF ref: mdref= MDItemCreate(nil, (CFStringRef)path); [NSMakeCollectable(mdref) autorelease]; I think I'm doing the right thing in the class declaration: @interface MetadataItem : NSObject { __strongMDItemRefmdref; @end But every now and then: CFTypeRefres = MDItemCopyAttribute(mdref, (CFStringRef)key); this makes it crash horribly. It's got to have something to do with garbage collection, but it seems like I'm doing things right. Any thoughts? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
[iPhone] Grouped TableView baffling problem
Hi, I have a table view with 3 grouped sections. Each section contains only one item. There is a baffling problem i don't have a clue what went wrong. if any one of the single row in any section is selected for the first time. All is well, the correct next view will get pushed without problem. but if i select the back button and come back to the table view and try to select the same or another row. I get dropped into the debugger with the following message: Loading program into debugger… GNU gdb 6.3.50-20050815 (Apple version gdb-962) (Sat Jul 26 08:14:40 UTC 2008) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type show copying to see the conditions. There is absolutely no warranty for GDB. Type show warranty for details. This GDB was configured as i386-apple-darwin.warning: Unable to read symbols for /System/Library/Frameworks/UIKit.framework/UIKit (file not found). warning: Unable to read symbols from UIKit (not yet mapped into memory). warning: Unable to read symbols for /System/Library/Frameworks/ CoreGraphics.framework/CoreGraphics (file not found). warning: Unable to read symbols from CoreGraphics (not yet mapped into memory). Program loaded. sharedlibrary apply-load-rules all Attaching to program: `/Users/linjames/Library/Application Support/ iPhone Simulator/User/Applications/541FCE53-8B6A-4878-BD9B- FDAE34C62CB1/KindredSpirit.app/KindredSpirit', process 21184. as you can see, this doesn't help tell me what went wrong...am I missing something? Thank you in advance... James___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: [iPhone] Grouped TableView baffling problem
Not much of an iPhone dev, but have you checked where you are when the debugger kicks in? `where` in the the gdb console or just looking at the Debugger panel (or the status bar) will usually tell you. From the empty debug console it sounds like you're breaking on objc_exception_throw and just not noticing it; if you are, single-step through the program until it prints out the exception to the console. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: ViewControllers and window nibs
On 6 May 2009, at 21:01, jonat...@mugginsoft.com wrote: See the following for hints on binding across nibs. http://homepage.mac.com/mmalc/CocoaExamples/controllers.html I have a *vaguely* similar question: In IB, is it possible to connect an object in one NIB to an outlet in another NIB? Dragging a connection in IB across NIBs doesn't seem to work, so I suspect it is not possible?? PS: I know other solutions, e.g. code or bindings, but I am just wondering why I can't do it in IB... Dez ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
problem with NSTimer
according to documentation for beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo: it says that While the application is in the run loop, it does not respond to any other events (including mouse, keyboard, or window- close events) unless they are associated with the sheet. It also does not perform any tasks (such as firing timers) that are not associated with the modal run loop. But in my app the timer i had created fires even my main window is in running as Modal - (id)init { self = [super init]; if (self) { timer = [NSTimer scheduledTimerWithTimeInterval:5.0f target:self selector:@selector(timerPinged:) userInfo:nil repeats:YES]; } return self; } -(void)timerPinged:(NSTimer*)timere { NSLog(@timer pinged); } -(IBAction)raiseSheet:(id)sender { [NSApp beginSheet:syncPanel modalForWindow:window modalDelegate:nil didEndSelector:nil contextInfo:nil]; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: ViewControllers and window nibs
On Fri, May 8, 2009 at 5:51 AM, Derek Chesterfield d...@mac.com wrote: I have a *vaguely* similar question: In IB, is it possible to connect an object in one NIB to an outlet in another NIB? Dragging a connection in IB across NIBs doesn't seem to work, so I suspect it is not possible?? No, it's not. PS: I know other solutions, e.g. code or bindings, but I am just wondering why I can't do it in IB... Because it doesn't make sense. While things within a nib are reconstituted together, there's no logical relationship between two nibs. You might instantiate a nib dozens of times (think of your document nib) but only instantiate other nibs once (think your main menu nib). What sense would it make to wire things up between the nibs? And how would IB know that it doesn't make sense? --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
iPhone how to suppress phone dialer screen
Hi, I am writing an application which is in landscape mode. It dials a phone number using the tel protocol. While dialing the standard iPhone dialer screen pops up. Is there any means by which this screen can be suppressed? Or how can I make this screen device orientation aware? Is there any other means by which the same can be achieved without using the tel protocol? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: iPhone how to suppress phone dialer screen
On May 8, 2009, at 7:35 AM, Shraddha Karwan wrote: Hi, I am writing an application which is in landscape mode. It dials a phone number using the tel protocol. While dialing the standard iPhone dialer screen pops up. Is there any means by which this screen can be suppressed? Or how can I make this screen device orientation aware? Is there any other means by which the same can be achieved without using the tel protocol? Please don't suppress the standard dialer screen. As long as it remains, the user has no doubt about what you're doing, and how to interact with the interface. It would worry me if there *was* a way to suppress it. Control of the device belongs to the user, and providing a single funnel interface (the tel: protocol and its associated UI) to the dialing system brings us one step closer to assuring that. -- Gwynne, Daughter of the Code This whole world is an asylum for the incurable. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: iPhone how to suppress phone dialer screen
On Fri, May 8, 2009 at 5:16 PM, Gwynne Raskind gwy...@darkrainfall.orgwrote: Please don't suppress the standard dialer screen. As long as it remains, the user has no doubt about what you're doing, and how to interact with the interface. It would worry me if there *was* a way to suppress it. Control of the device belongs to the user, and providing a single funnel interface (the tel: protocol and its associated UI) to the dialing system brings us one step closer to assuring that. -- Gwynne, Daughter of the Code This whole world is an asylum for the incurable. Thanks for the response. So is there any means by which I can change the orientation of the dialer when the device orientation changes? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Custom NSImageView
Corbin Dunn ha scritto: On May 7, 2009, at 8:16 AM, Livio Isaia wrote: I create MyImageView (from NSImageView) which must use MyImageCell (from NSImageCell). I put MyImageView in MyWindow with Interface Builder, creating an NSImageView and setting its class to MyImageView. The cell is encoded in the nib. You can change it by double clicking on the MyImageView in IB to select the cell. Then change the class to MyImageCell in the info window of IB. corbin Sorry, but I tried to double click on MyImageView in IB but nothing happens, the attributes inspector for it remains the same and doesn't show any choice about the cell. Perhaps I misunderstand you? thanks, regards, livio. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: iPhone how to suppress phone dialer screen
On May 8, 2009, at 6:59 AM, Shraddha Karwan wrote: On Fri, May 8, 2009 at 5:16 PM, Gwynne Raskind gwy...@darkrainfall.org wrote: Please don't suppress the standard dialer screen. As long as it remains, the user has no doubt about what you're doing, and how to interact with the interface. It would worry me if there *was* a way to suppress it. Control of the device belongs to the user, and providing a single funnel interface (the tel: protocol and its associated UI) to the dialing system brings us one step closer to assuring that. -- Gwynne, Daughter of the Code This whole world is an asylum for the incurable. Thanks for the response. So is there any means by which I can change the orientation of the dialer when the device orientation changes? You should check/ask on the official iPhone developer forums: http://devforums.apple.com/ where issues like this have been discussed in the past. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: iPhone how to suppress phone dialer screen
On Fri, May 8, 2009 at 4:59 AM, Shraddha Karwan shraddha.kar...@gmail.comwrote: On Fri, May 8, 2009 at 5:16 PM, Gwynne Raskind gwy...@darkrainfall.org wrote: Please don't suppress the standard dialer screen. As long as it remains, the user has no doubt about what you're doing, and how to interact with the interface. It would worry me if there *was* a way to suppress it. Control of the device belongs to the user, and providing a single funnel interface (the tel: protocol and its associated UI) to the dialing system brings us one step closer to assuring that. -- Gwynne, Daughter of the Code This whole world is an asylum for the incurable. Thanks for the response. So is there any means by which I can change the orientation of the dialer when the device orientation changes? You should never change the orientation of the dialer. Why? The receiver is at the top of the device and transmitter (i.e. mic) is at the bottom of the device. Thus, when one answers a call or makes a call, the phone will be in portrait orientation. Please don't try to implement feature(s) that violates the user experience on the iPhone. Thus, I would highly recommend reading the following: iPhone Human Interface Guidelineshttp://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/MobileHIG/index.html Good luck, -Conrad ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
quick and dirty NSData implosion
so far, what i've determined by dumbing this down, is that I must be doing something inherently bad and nubi like here... the run time just completely implodes when it gets to the NSData line of code any help would be great, thanks in advance. the BookMark is just a class with the 3 items that you can see below in it, and then uses the @property and @synthesize routines to set the setter and getter, there is nothing else in the class. I suspect that NSData's keyedArchiver is not expecting a mutable thing? but NSUserDefaults only takes immutable things. NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; BookMark *theBookMark = [[BookMark alloc] init]; NSString *theurl = @http:/.anything.com/; NSMutableDictionary *bookMarkList = [[NSMutableDictionary alloc] initWithCapacity: 9]; bookMarkCount++; [theBookMark setBookMarkCount:bookMarkCount]; [theBookMark setBookMarkurlString:theurl]; [theBookMark setBookMarkTitle:[docTitle substringToIndex:100]]; NSString *countString = [NSString stringWithFormat:@%d, bookMarkCount]; [bookMarkList setObject:theBookMark forKey:countString]; NSData *bookMarkdata = [NSKeyedArchiver archivedDataWithRootObject:bookMarkList]; [defaults setObject:bookMarkdata forKey:PECBookMarkListKey]; ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: quick and dirty NSData implosion
Am 08.05.2009 um 15:25 schrieb Jon: but NSUserDefaults only takes immutable things. Why do you think that? Did you try? From the documentation: value The object to store in the defaults database. A default’s value can be only property list objects: NSData, NSString, NSNumber, NSDate, NSArray, or NSDictionary. An NSMutableDictionary is a subclass of NSDictionary. Why should it be illegal to throw it in there? It is still an NSDictionary. The important part is that it must be a property list object. atze ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSXMLParser frees itself on error?
On Fri, May 8, 2009 at 1:43 AM, Marcel Weiher marcel.wei...@gmail.com wrote: On May 7, 2009, at 21:12 , Michael Ash wrote: On Thu, May 7, 2009 at 11:53 PM, Marcel Weiher marcel.wei...@gmail.com wrote: On May 7, 2009, at 17:29 , Jeff Johnson wrote: On May 7, 2009, at 6:00 PM, Marcel Weiher wrote: That's not what I was talking about. I was talking about the possibility that the 'owned' caller manually runs the run loop right after it calls the delegate callback, so any performSelector: called by the delegate will be performed after the delegate callback returns but within the scope of the caller. How do you protect against that? *I* don't. It is you who wants these sorts of guarantees and protections. I code in ways that don't assume these sorts of protections. How? Begin forwarded message: From: Marcel Weiher marcel.wei...@gmail.com Date: May 7, 2009 10:05:29 PDT And yes, the code that I use explicitly runs the runloop, and it is the code that runs the runloop that both allocates the NSURLConnection and then cleans up after it checks the flag. Perfectly safe, perfectly synchronous. And what about the *a*synchronous case? That *was* the asynchronous case, which I then proceeded to make synchronous. Which means it's synchronous. How would you handle an asynchronous connection? 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: problem with NSTimer
On Fri, May 8, 2009 at 5:51 AM, Kiran Kumar S kirankuma...@prithvisolutions.com wrote: according to documentation for beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo: it says that While the application is in the run loop, it does not respond to any other events (including mouse, keyboard, or window-close events) unless they are associated with the sheet. It also does not perform any tasks (such as firing timers) that are not associated with the modal run loop. But in my app the timer i had created fires even my main window is in running as Modal The documentation is completely broken here. That's not how sheets work. Sheets only block events to the window they are associated with. Events to other windows work just fine. You can see this by bringing up the standard save sheet in, say, TextEdit, and observing how you can still create new documents, edit other open documents, etc. As such, the fact that timer still fire is completely expected. I recommend you file a bug against the documentation. It seems that they did a copy/paste job from the -runModalForWindow: method despite the fact that they work nothing alike. 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: quick and dirty NSData implosion
yes i did try, i would send the data, and nothing would show up in the property list file. but there would be no crash, no error, nothing, but no results either. so after reading the same documentation you also saw, I assumed it had to be NSDictionary, rather than NSMutableDictionary. It is most likely the wrong assumption, but i could get nothing from the line of code below. here is the line i used... simply substituting this in, instead of the NSData stuff, and atleast it doesn't crash and burn... but it also produces nothing in the property list. [defaults setObject:bookMarkList forKey:PECBookMarkListKey]; so again, I must be doing something fundamentally wrong here? this also does not explain why the NSData line of code would implode, even if my assumption was wrong in that case, something else must also be wrong there. Jon. On May 8, 2009, at 7:39 AM, Alexander Spohr wrote: Why do you think that? Did you try? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
HFS Format API?
Is there a Cocoa/Core Foundation (or ___) API for formatting a Volume? Rich Collyer ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: quick and dirty NSData implosion
Why don't you do something like this: @try { [defaults setObject:bookMarkList forKey:PECBookMarkListKey]; } @catch (NSException *e) { NSLog(@NSData blew up because: %@, [e reason]); } and find out what the error is? John On 8-May-09, at 9:56 AM, jon wrote: yes i did try, i would send the data, and nothing would show up in the property list file. but there would be no crash, no error, nothing, but no results either. so after reading the same documentation you also saw, I assumed it had to be NSDictionary, rather than NSMutableDictionary. It is most likely the wrong assumption, but i could get nothing from the line of code below. here is the line i used... simply substituting this in, instead of the NSData stuff, and atleast it doesn't crash and burn... but it also produces nothing in the property list. [defaults setObject:bookMarkList forKey:PECBookMarkListKey]; so again, I must be doing something fundamentally wrong here? this also does not explain why the NSData line of code would implode, even if my assumption was wrong in that case, something else must also be wrong there. Jon. On May 8, 2009, at 7:39 AM, Alexander Spohr wrote: Why do you think that? Did you try? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/john_cebasek%40sympatico.ca This email sent to john_ceba...@sympatico.ca ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Associating Objective-C objects with Java objects using JNI
It can certainly be done; I did something exactly analogous ~7 years ago for C++ Carbon. Basically, you can use the JNI to instantiate a Java runtime instance within your program, then use JNI to call through to Java object instances. Backing out a bit, you can create your own proxy classes whose instances hold a reference to a Java object, and have methods that mirror those of the Java object, and just delegate to the Java object via the JNI. Backing out one more step, you can use reflection to automatically generate a wrapper class for any Java class. Backing out one more step, for a given Javan class, you can generate wrapper classes for any Java class returned by or taken as an argument by a method of that class, recursively. As for memory management, your proxies would be reference-counted like normal Objective-C instances, and on dealloc they would release their Java delegate objects. There's some work involved, that's for sure. But it's really not all that complicated. One suggestion specific to your stated plan: forget any special annotations for methods, just generate methods in the Objective-C proxy for all methods in the Java class. -- Scott Ribe scott_r...@killerbytes.com 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 arch...@mail-archive.com
Re: quick and dirty NSData implosion
Am 08.05.2009 um 15:56 schrieb jon: [defaults setObject:bookMarkList forKey:PECBookMarkListKey]; so again, I must be doing something fundamentally wrong here? Yes. Your BookMark-instance is not a property list object. So you could store the NSMutableDictionary, but it holds an illegal object. Therefore the defaults will ignore it. this also does not explain why the NSData line of code would implode, even if my assumption was wrong in that case, something else must also be wrong there. I can not see a problem at first glace. Maybe you could provide a stack trace? Implode is a bit vague :) atze ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cancel NSThread - cocoa/mysql database search...
Thanks... I tried both the ways as Bill and Mike suggested. I could manage to cancel the thread by checking the bool flag for cancellation. It works fine. But the problem I am facing now is, once i sent the query to MySQL through SMySQL framework, I am unable to cancel it. This query takes so much time to return the results and cannot be canceled as far as I understand. Is there any way to cancel this query??? any command or API!!! Once again Thanks guys... -- Best Regards, Sparta... On Wed, May 6, 2009 at 9:34 PM, Bill Bumgarner b...@mac.com wrote: On May 6, 2009, at 8:22 AM, Sparta wrote: I am working on cocoa – MySQL application that connects to the MySQL database and retrieves the records. I run the search in a NSThread. I wish to cancel the search if needed, as the searching of the desired data takes 15-20 minutes due to the bigger size of database. Please suggest some method which can cancel / exit the NSThread from the parent thread. Something like this: BOOL stopItMan; - (void) doSomePotentiallyLongWindedStuffOnASecondThread { while (!stopItMan) { do some more stuff }; } - (void) userIsImpatientStopItNow { stopItMan = YES; } Don't do something like this (which is possible and would require calling through to some bits of lower level mach or pthread API): - (void) userIsImpatientStopItNow { nukeBackgroundThreadFromSpace(); } You can't kill a thread arbitrarily as there is no way to know what state the thread might be in when you kill it unless you do the work necessary to cause the targeted thread to be blocked at a known safe point in its execution. However, if the thread is blocked at a known safe point, that known safe point can just as easily be a test to see if should continue, exiting safely if not. 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: quick and dirty NSData implosion
And just to make sure... your Bookmark class does implement NSCoding, correct? That's required by NSKeyedArchiver. Dave On May 8, 2009, at 8:05 AM, Alexander Spohr wrote: Am 08.05.2009 um 15:56 schrieb jon: [defaults setObject:bookMarkList forKey:PECBookMarkListKey]; so again, I must be doing something fundamentally wrong here? Yes. Your BookMark-instance is not a property list object. So you could store the NSMutableDictionary, but it holds an illegal object. Therefore the defaults will ignore it. this also does not explain why the NSData line of code would implode, even if my assumption was wrong in that case, something else must also be wrong there. I can not see a problem at first glace. Maybe you could provide a stack trace? Implode is a bit vague :) atze ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/davedelong%40me.com This email sent to davedel...@me.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: quick and dirty NSData implosion
Not quite. It can if it's encoded first (with something like NSKeyedArchiver, and it can only be archived if it conforms to NSCoding. Dave On May 8, 2009, at 8:14 AM, Keary Suska wrote: ...your BookMark class cannot be stored in defaults... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Distributed Objects via Bonjour?
Good DO demo code is rather scarce, and the best-practices are highly dependent on the target OS. For one example showing about every permutation imaginable, and a little-recognized simplified Bonjour strategy, try: http://thotzy.com/THOTZY/Distributed_Objects_Demo.html The demo builds an app that lets you do intra and inter Mac DO, and explores several threading strategies. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: quick and dirty NSData implosion
This is a clear indication that your BookMark class does not conform to NSCoding. Check the docs on what NSCoding is and how to use it. If you implement the two required methods (initWithCoder: and encodeWithCoder:), your code should work just fine. Dave On May 8, 2009, at 8:35 AM, jon wrote: NSData blew up because: *** -[BookMark encodeWithCoder:]: unrecognized selector sent to instance 0x1f900a40 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: quick and dirty NSData implosion
Am 08.05.2009 um 16:35 schrieb jon: NSData blew up because: *** -[BookMark encodeWithCoder:]: unrecognized selector sent to instance 0x1f900a40 So what are you asking for? It’s right there in your face: Your BookMark does not implement encodeWithCoder: an is therefore not NSCoding compliant. Just what Dave said. Implement it and it should work. atze ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: quick and dirty NSData implosion
sorry, I am getting emails out of order because i'm using the option that sends list in a bundle, so getting the ones that reply directly to me first, so i am looking for Dave's answer now... thanks, Jon. On May 8, 2009, at 8:40 AM, Alexander Spohr wrote: So what are you asking for? It’s right there in your face: Your BookMark does not implement encodeWithCoder: an is therefore not NSCoding compliant. Just what Dave said. Implement it and it should work. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
NSApplication and command line args
Hi, For those of you familiar with handling command line arguments with an NSApplication, I am requesting a reality-check whether I am understanding the following problem correctly, and whether the proposed solution makes sense. Please reply directly to me off-line unless you believe the answer to be of public value, thanks! I have recently converted an application which processes command line arguments to call NSApplicationMain when it starts up, and defer command line processing until later in a separate thread. The deferred command line processing still works; however, I am seeing a new behavior where, in some circumstances, NSApplication is passing certain arguments to openFiles, which is undesirable. For example, there may be a command line argument '-logfile /foo/bar', where '/foo/ bar' is also being passed to openFiles. My proposed solution is to detect when an argument is being passed to openFiles during startup (i.e., when the arguments are being processed), and filter it out. I do this by using a boolean flag which is initialized to false and set to true when applicationDidFinishLaunching is called on my delegate. If openFiles is called when sIsRunning is false, I perform this extra check if it's on the command line and ignore it if it is. namespace { bool sIsRunning = false; }; bool isFileNameCommandLineArgument(NSString *fileName) { bool found = false; // If we are called while starting up, we need to filter out any fileNames which match a // command line argument. This is because -display and -logfile parameters will cause NSApplication // to call handleOpenDocument, which is not the desired behavior. // Once started up, we don't attempt to filter. if (!sIsRunning) { const char* fileNameCStr = [fileName cStringUsingEncoding: NSASCIIStringEncoding]; char **argv = *_NSGetArgv(); for (int i = 0; argv[i] != NULL; ++i) { // Only check non-zero length non-leading-dash arguments if (argv[i][0] 0 argv[i][0] != '-' strcmp(fileNameCStr, argv[i]) == 0) { found = true; } } } return found; } In my application delegate, implement applicationDidFinishLaunching and filter file names in openFiles: - (void) applicationDidFinishLaunching:(NSNotification *)aNotification { sIsRunning = true; } - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames { NSUInteger i; for( i = 0; i [filenames count]; i++) { NSString *fileName = [filenames objectAtIndex: i]; if (!isFileNameCommandLineArgument(fileName)) { handleOpenDocument(fileName); } } } This appears to resolve the problem. Did I understand the problem correctly, and is this the best way to keep openFiles from opening files which happen to be passed as command line arguments? Are there other avenues/methods I should explore? - Brian Mac Developer The MathWorks, Inc. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Converting NSString to C++ std::string
Im using a library which requires arguments to be C++ std::strings, but I need to take the value from an NSTextField. I thought I could do it like this: std::string mycppstring; . . . mycppstring = std::string([[myNSTextField stringValue] UTF8String]); But it keeps crashing. What's the recommended way? Thanks Andrew ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSXMLNode bug in method XMLString
I am a long time programmer returning to Mac development, so pardon if I'm not following protocol. I submitted this bug to the Apple Bug Reporter (id 6693016) about two months ago and it's just been sitting there with no response. From my searching of the archives it seems that no-one has reported this, so I'm submitting it here so at least some other people can find it via Google. The XMLString method of NSXMLNode gets it wrong for a NSNumber object, set as an object, that is a simple power of ten. This bit me while writing code to export data. Here is a nice compact demo of the bug: #import Foundation/Foundation.h int main (int argc, const char * argv[]) { // Garbage collection required NSNumber *numberOneHundred = [NSNumber numberWithDouble:100.0]; NSNumber *numberOneHundredAndSmidge = [NSNumber numberWithDouble: 100.01]; NSXMLElement *nodeGood1 = [NSXMLNode elementWithName:@Percentage stringValue:[numberOneHundred stringValue]]; NSXMLElement *nodeGood2 = [NSXMLNode elementWithName:@Percentage stringValue:[numberOneHundredAndSmidge stringValue]]; NSXMLElement *nodeGood3 = [NSXMLNode elementWithName:@Percentage]; [nodeGood3 setObjectValue:numberOneHundredAndSmidge]; NSXMLElement *nodeError = [NSXMLNode elementWithName:@Percentage]; [nodeError setObjectValue:numberOneHundred]; NSLog(@Good1: %@, [nodeGood1 XMLString]); NSLog(@Good2: %@, [nodeGood2 XMLString]); NSLog(@Good3: %@, [nodeGood3 XMLString]); NSLog(@Error: %@, [nodeError XMLString]); return 0; } Produces (XCode 3.1.2, OS X 10.5): 2009-03-17 21:28:15.002 XMLWriteBug[22663:10b] Good1: Percentage100/ Percentage 2009-03-17 21:28:15.013 XMLWriteBug[22663:10b] Good2: Percentage100.01/Percentage 2009-03-17 21:28:15.015 XMLWriteBug[22663:10b] Good3: Percentage1.0001E2/Percentage 2009-03-17 21:28:15.015 XMLWriteBug[22663:10b] Error: Percentage10E2/Percentage Notice that last line should be 1.0E2 or 1E2 or 10E1, but not 10E2 -- Ken Chin-Purcell Bungalow Pottery k...@bungalowpottery.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
NSString to bit pattern
Hi, I am trying to find way to convert the NSString object into its bit pattern and convert that bit pattern into another NSString object, For Example if I have NSString *origStr = @Hello: NSString * bitPatternoforigStr ; no I want to convert it to the bit pattern if Hello and return an object of type NSString with bit pattern. it should be something like; bitPatternoforigStr = @01011010011000100100110101100101 ; Can someone help me in this. Thanks, ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
RE: problem with NSTimer
I am guessing you will have to configure your runloop in the appropriate mode (see NSRunLoop, and Run Loop Management in the docs), to specify the behavior of your timers. Hope that helped, ~Gopinath -Original Message- From: cocoa-dev-bounces+gopinath=adobe@lists.apple.com [mailto:cocoa-dev-bounces+gopinath=adobe@lists.apple.com] On Behalf Of Kiran Kumar S Sent: Friday, May 08, 2009 3:21 PM To: Apple Mailing Mailing Subject: problem with NSTimer according to documentation for beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo: it says that While the application is in the run loop, it does not respond to any other events (including mouse, keyboard, or window- close events) unless they are associated with the sheet. It also does not perform any tasks (such as firing timers) that are not associated with the modal run loop. But in my app the timer i had created fires even my main window is in running as Modal - (id)init { self = [super init]; if (self) { timer = [NSTimer scheduledTimerWithTimeInterval:5.0f target:self selector:@selector(timerPinged:) userInfo:nil repeats:YES]; } return self; } -(void)timerPinged:(NSTimer*)timere { NSLog(@timer pinged); } -(IBAction)raiseSheet:(id)sender { [NSApp beginSheet:syncPanel modalForWindow:window modalDelegate:nil didEndSelector:nil contextInfo:nil]; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/gopinath%40adobe.com This email sent to gopin...@adobe.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: Converting NSString to C++ std::string
--- On Thu, 5/7/09, Andrew Wood ajw...@iee.org wrote: From: Andrew Wood ajw...@iee.org Subject: Converting NSString to C++ std::string To: Cocoa-dev@lists.apple.com Date: Thursday, May 7, 2009, 4:38 PM Im using a library which requires arguments to be C++ std::strings, but I need to take the value from an NSTextField. I thought I could do it like this: std::string mycppstring; . . . mycppstring = std::string([[myNSTextField stringValue] UTF8String]); But it keeps crashing. What's the recommended way? Try: [thisOptionNSString cStringUsingEncoding: NSASCIIStringEncoding] where thisOptionNSString is of NSString * type, and has already been properly initialized and allocated. vinai ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSString to bit pattern
erappy wrote: Hi, I am trying to find way to convert the NSString object into its bit pattern and convert that bit pattern into another NSString object, For Example if I have NSString *origStr = @Hello: NSString * bitPatternoforigStr ; no I want to convert it to the bit pattern if Hello and return an object of type NSString with bit pattern. it should be something like; bitPatternoforigStr = @01011010011000100100110101100101 ; Can someone help me in this. Break it down. A string is a sequence of characters. Retrieve each character, determine its bit-pattern, then append that pattern to an NSMutableString. Now you have to figure out how to turn a character into its bit-pattern. So break that down. A character (or any simple non-floating type) is a sequence of bits. If you know the C operators for Boolean AND and SHIFTS ( and and ), then you know enough to isolate single bits from a character. Then you just test each bit and append either a '0' or '1' character to the accumulating NSMutableString. -- GG ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Converting NSString to C++ std::string
That should work. Where are you crashing - and what is your crash log? My guess is that something else is not right (are you sure that myNSTextField is a valid object)? Jesper Storm Bache On May 7, 2009, at 2:38 PM, Andrew Wood wrote: Im using a library which requires arguments to be C++ std::strings, but I need to take the value from an NSTextField. I thought I could do it like this: std::string mycppstring; . . . mycppstring = std::string([[myNSTextField stringValue] UTF8String]); But it keeps crashing. What's the recommended way? Thanks Andrew ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/jsbache%40adobe.com This email sent to jsba...@adobe.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: Converting NSString to C++ std::string
Probably you can read this document in following link... http://developer.apple.com/documentation/Cocoa/Conceptual/Strings/Articles/CreatingStrings.html This talks about how to C string. And after that you can convert that into a C++ string object. On Fri, May 8, 2009 at 9:39 PM, Alexander Spohr a...@freeport.de wrote: Am 07.05.2009 um 23:38 schrieb Andrew Wood: mycppstring = std::string([[myNSTextField stringValue] UTF8String]); But it keeps crashing. What's the recommended way? Does std::string() copy the char* contents? I guess not (but I don’t use C++). See the docs: UTF8String Returns a null-terminated UTF8 [...] Discussion _The_returned_C_string_is_automatically_freed_ just as a returned object would be released; you should copy the C string if it needs to store it outside of the autorelease context in which the C string is created. Could that be your problem? atze ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/cocoa.learner%40gmail.com This email sent to cocoa.lear...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Converting NSString to C++ std::string
On 8-May-09, at 8:55 AM, cocoa-dev-requ...@lists.apple.com wrote: mycppstring = std::string([[myNSTextField stringValue] UTF8String]); But it keeps crashing. What's the recommended way? I have no idea, but it works for me to simply assign it without the constructor. Why, here's an example in the file I'm working on right now, fancy that: - (BOOL)willInterceptURL:(NSURL*)url { // copied from the Carbon version since that works std::string urlstring = [[url resourceSpecifier] UTF8String]; ... } I've done the same thing all sorts of places grafting shiny Cocoa stuff onto old C++ code that works and never noticed any issues. -- Alex Curylo -- a...@alexcurylo.com -- http://www.alexcurylo.com/ I guess it's pretty bad when you don't start using a new API until it's been deprecated. -- Nick Nallick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Getting the private IP
On Fri, May 8, 2009 at 10:46 AM, Mr. Gecko grmrge...@gmail.com wrote: Hello, I'm trying to find out how to get the private IP address. If I understand your code correctly, you're trying to get the loopback address? No need for all of this, then. The IPv4 loopback address is 127.0.0.1 by definition. The IPv6 loopback address is ::1 by definition. There is no need to look them up, because they are defined in the standard and cannot change. 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: [Q] Correct way to identify an application, Launch Services, Spaces
On May 7, 2009, at 10:40 AM, Eric Gorr wrote: So, is it the right thing for two versions of the application to have the same identifier? That's the typical approach, although there are lots of apps that change their identifier with each release too. Spaces does identify apps strictly by bundle identifier, so if you really want the ability to associate different versions of your app with different spaces, then you must change the bundle identifier for each application version. By doing that, you'll break any other bindings that the user may have specified, for example to have certain documents open with your application rather some other app. -eric ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Converting NSString to C++ std::string
On Fri, May 8, 2009 at 8:39 AM, Alexander Spohr a...@freeport.de wrote: Am 07.05.2009 um 23:38 schrieb Andrew Wood: mycppstring = std::string([[myNSTextField stringValue] UTF8String]); But it keeps crashing. What's the recommended way? Does std::string() copy the char* contents? I guess not (but I don’t use C++). Yes, it does copy the string. As presented, the OP's code is correct, and should work. OP: You'll have to provide some more information as to what is actually going wrong (especially where the crash is actually happening). -- Clark S. Cox III clarkc...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iPhone] Grouped TableView baffling problem
I would expect that the backtrace will give a clue as to what's going on. Luke On May 8, 2009, at 1:04 AM, James Lin wrote: Hi, I have a table view with 3 grouped sections. Each section contains only one item. There is a baffling problem i don't have a clue what went wrong. if any one of the single row in any section is selected for the first time. All is well, the correct next view will get pushed without problem. but if i select the back button and come back to the table view and try to select the same or another row. I get dropped into the debugger with the following message: Loading program into debugger… GNU gdb 6.3.50-20050815 (Apple version gdb-962) (Sat Jul 26 08:14:40 UTC 2008) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type show copying to see the conditions. There is absolutely no warranty for GDB. Type show warranty for details. This GDB was configured as i386-apple-darwin.warning: Unable to read symbols for /System/Library/Frameworks/UIKit.framework/ UIKit (file not found). warning: Unable to read symbols from UIKit (not yet mapped into memory). warning: Unable to read symbols for /System/Library/Frameworks/ CoreGraphics.framework/CoreGraphics (file not found). warning: Unable to read symbols from CoreGraphics (not yet mapped into memory). Program loaded. sharedlibrary apply-load-rules all Attaching to program: `/Users/linjames/Library/Application Support/ iPhone Simulator/User/Applications/541FCE53-8B6A-4878-BD9B- FDAE34C62CB1/KindredSpirit.app/KindredSpirit', process 21184. as you can see, this doesn't help tell me what went wrong...am I missing something? Thank you in advance... James___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/luketheh%40apple.com This email sent to luket...@apple.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
Not sleeping - Why?
My app is a background app that sends and receives distributed notifications, reads from a few large mmap'd files and crates a new file every few minutes (and deletes the old one). When it is running, the display sleeps, but the system does not. How can I tell the OS that it is ok to sleep. Since I don't have a GUI, there is never any user interaction. Is it not sleeping because I am creating files? Thanks, Trygve ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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] Correct way to identify an application, Launch Services, Spaces
On May 8, 2009, at 12:38 PM, Eric Schlegel wrote: On May 7, 2009, at 10:40 AM, Eric Gorr wrote: So, is it the right thing for two versions of the application to have the same identifier? That's the typical approach, although there are lots of apps that change their identifier with each release too. Spaces does identify apps strictly by bundle identifier, so if you really want the ability to associate different versions of your app with different spaces, then you must change the bundle identifier for each application version. By doing that, you'll break any other bindings that the user may have specified, for example to have certain documents open with your application rather some other app. Thank you for this useful information. My only other question would involve whether or not there would be undesirable side-effects by having different identifiers for different versions of the application. Are you (or anyone else) aware of any issues I should be aware of? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Converting NSString to C++ std::string
According to Alex Curylo: On 8-May-09, at 8:55 AM, cocoa-dev-requ...@lists.apple.com wrote: mycppstring = std::string([[myNSTextField stringValue] UTF8String]); But it keeps crashing. What's the recommended way? I have no idea, but it works for me to simply assign it without the constructor. Why, here's an example in the file I'm working on right now, fancy that: The only other gotcha I can think of (because it annoys me) is that std::string does not play nice with null pointers. Is it possible that stringValue returns nil? Hmm, I had one other thought. There are several std::string constructors, depending on the parameter type. In ObjC++, is it unambiguous at compile time that the expression is const char*? -- Drew Lawson| We were taking a vote when | the ground came up and hit us. | -- Cylon warrior ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Tri-state Check box
In my app, the check box is in the table column and i have binded the value of table column to a BOOL variable of my model class. In this case how do i set the Mixed State to a particulat item in the table column. Thanks Arun On Fri, May 8, 2009 at 1:05 AM, Eric Gorr mail...@ericgorr.net wrote: If I understand correctly, when the user changes the state, simply do: [myCheckBox setAllowsMixedState:NO]; On May 7, 2009, at 1:36 PM, Arun wrote: Hi All, In my application i use check box to represent enable / disable states. And user is allowed to change the states from enable to disable and vice versa. Is it possible to represent one more state say modified using the same check box? I know if i set the state of the check box to mixed i can represent more than 2 states in check box. But My requirement is that, i should be able to represent more than two state bu when user changes the state, it should be either enable/disable and never to select modified state. Is it possible to achieve this in check box? Any idea? 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/mailist%40ericgorr.net This email sent to mail...@ericgorr.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: iPhone Telephone APIs
On May 8, 2009, at 1:03 PM, Luke the Hiesterman wrote: On May 8, 2009, at 10:00 AM, we...@mindspring.com wrote: If you feel strongly (like I do) that this functionality should be made available, file a bug. I'm thinking there is a legal reason this feature is not enabled, but I am unable to confirm my suspicions. Why do you feel you should be able to interact with a phone call? Phone calls on a telephone are inherently (and I would say, clearly) the sole domain and responsibility of the telephone operating system. Telephones that have operating systems... Does anyone remember those old rotary assemblages that were mostly mechanical and took up almost the same space as a brick of ice cream and had big four-prong plugs? THOSE sure as hell didn't have an OS. I feel old now :). In any case, it might be more correct to say that phone calls on a telephone are ultimately (and conceptually purely) the domain of the user. I for one would shudder to think that arbitrary applications on my iPhone could interact with the baseband firmware at all, nevermind at the level of actually making telephone calls. I hope Apple *never* makes this functionality available, ever. -- Gwynne, Daughter of the Code This whole world is an asylum for the incurable. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: iPhone Telephone APIs
Apologies for the random e-mail from nowhere; I replied to the wrong list. On May 8, 2009, at 1:17 PM, Gwynne Raskind wrote: On May 8, 2009, at 1:03 PM, Luke the Hiesterman wrote: On May 8, 2009, at 10:00 AM, we...@mindspring.com wrote: If you feel strongly (like I do) that this functionality should be made available, file a bug. I'm thinking there is a legal reason this feature is not enabled, but I am unable to confirm my suspicions. Why do you feel you should be able to interact with a phone call? Phone calls on a telephone are inherently (and I would say, clearly) the sole domain and responsibility of the telephone operating system. Telephones that have operating systems... Does anyone remember those old rotary assemblages that were mostly mechanical and took up almost the same space as a brick of ice cream and had big four-prong plugs? THOSE sure as hell didn't have an OS. I feel old now :). In any case, it might be more correct to say that phone calls on a telephone are ultimately (and conceptually purely) the domain of the user. I for one would shudder to think that arbitrary applications on my iPhone could interact with the baseband firmware at all, nevermind at the level of actually making telephone calls. I hope Apple *never* makes this functionality available, ever. -- Gwynne, Daughter of the Code This whole world is an asylum for the incurable. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/gwynne%40darkrainfall.org This email sent to gwy...@darkrainfall.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/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [Q] Correct way to identify an application, Launch Services, Spaces
On Fri, May 8, 2009 at 12:55 PM, Eric Gorr mail...@ericgorr.net wrote: Are you (or anyone else) aware of any issues I should be aware of? If you expose any scripting interface then people might get frustrated when their Frobdignag 2008 scripts don't work when they upgrade to Frobdignag 2009, even though the scripting dictionary hasn't changed. iTunes changes version number more frequently than most people change underwear, with the expectation that users only have one version installed at a time. I think you should expect the same for your users and use non-versioned bundle IDs. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [Q] Correct way to identify an application, Launch Services, Spaces
On May 8, 2009, at 09:55, Eric Gorr wrote: My only other question would involve whether or not there would be undesirable side-effects by having different identifiers for different versions of the application. Are you (or anyone else) aware of any issues I should be aware of? Well, for one thing, if you use different bundle identifiers you'll have different preferences files, so the applications won't by default share the same preferences. TBH, I don't see the virtue in letting Spaces' behavior be the determining factor. If Spaces can't tell the difference between application versions with the same bundle identifier, that's a defect in Spaces (from your point of view), not a reason for deforming your application to gain a small usability feature. OTOH, if your two versions really have a good reason for existing independently (beyond testing and an interim changeover period), then what you probably have is two different apps, and different bundle identifiers would make sense. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Tri-state Check box
Wire up a delegate and set the state in willDisplayCell. --Kyle Sluder -- --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [Q] Correct way to identify an application, Launch Services, Spaces
Thank you Kyle Quincey for your additional comments. I agree, it does not seem to be a good idea to give an application a different identifier based on the version changing. p.s. Anyone know how exactly Spaces builds the string that it uses? In my actual case, the name of the application showing up in Spaces was 'myapp 2008' if that was the application found first in the Launch Services Database, but if 'myapp 2009' was launched first, Spaces was showing only 'myapp'. If I look at the Launch Services database, I see: bundle id:# name: myapp in both cases. I'm just not sure where Spaces is getting the 'myapp 2008' string. The info.plist for myapp 2008 does not contain the string 'myapp 2008' either. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Garbage collector related crash
On May 8, 2009, at 12:47 AM, Chris Idou wrote: I've got an object that holds onto a CF ref: mdref= MDItemCreate(nil, (CFStringRef)path); [NSMakeCollectable(mdref) autorelease]; I think I'm doing the right thing in the class declaration: @interface MetadataItem : NSObject { __strongMDItemRefmdref; @end But every now and then: CFTypeRefres = MDItemCopyAttribute(mdref, (CFStringRef)key); this makes it crash horribly. It's got to have something to do with garbage collection, but it seems like I'm doing things right. Any thoughts? It is broken on Leopard (and fixed in a future release); please file a bug and send me the bug #. Attach your binary to the bug with steps to reproduce. One workaround for now -- not a very good workaround, but a workaround -- is to CFRetain the mdref as soon as you create it. Then never ever CFRelease it. Yes, it'll leak (fortunately these are small). But it won't crash (unless some other subsystem does code like yours above out of your control). 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: [Q] Correct way to identify an application, Launch Services, Spaces
On May 8, 2009, at 1:40 PM, Quincey Morris wrote: If Spaces can't tell the difference between application versions with the same bundle identifier, that's a defect in Spaces (from your point of view), not a reason for deforming your application to gain a small usability feature. If anyone is interested, I have filed a bug report: rdar://6870199 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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] Correct way to identify an application, Launch Services, Spaces
Never mind. It was probably just some weird glitch, but with some experimentation, Spaces is clearly grabbing the name it shows from the name of the app as it appears in the finder. On May 8, 2009, at 1:51 PM, Eric Gorr wrote: p.s. Anyone know how exactly Spaces builds the string that it uses? In my actual case, the name of the application showing up in Spaces was 'myapp 2008' if that was the application found first in the Launch Services Database, but if 'myapp 2009' was launched first, Spaces was showing only 'myapp'. If I look at the Launch Services database, I see: bundle id:# name: myapp in both cases. I'm just not sure where Spaces is getting the 'myapp 2008' string. The info.plist for myapp 2008 does not contain the string 'myapp 2008' either. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
AppleEvents and modal dialogs
I have a mostly-Carbon app that runs some Cocoa modal dialogs using -[NSApplication runModalForWindow:]. If an Apple Event (such as 'odoc') arrives while such a dialog is showing, it just gets eaten. I'd like to have it either handled or deferred. I tried creating an NSApplication delegate object, but its application:openFile: method doesn't get called. -- James W. Walker, Innoventive Software LLC http://www.frameforge3d.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
Renaming a file repositions icon in Finder
It appears that renaming a file will cause the Finder to reposition the icon for the file if it's currently displayed in a icon view somewhere. Is there any way to prevent that from happening? It looks very strange to have icons jump all over the place just because of a rename. Thinking that it might have been the method with which I was renaming the file, I tried NSFileManager's moveItemAtPath:toPath:error:, rename(), and FSRenameUnicode() and all three exhibit the same problem. -- Jim http://nukethemfromorbit.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: NSManagedObjectContext -insertObject: Cancels Prior Deletion -- BUT!
Conclusion. Here's what I believe to be the missing documentation... *** You can use -insertObject: to cancel a prior deletion, however if certain operations are performed after the deletion and before the restoring -insertObject:, the attributes of the deleted/inserted object will all be set to nil. These certain operations include, but may not be limited to, -[NSManagedObjectContext executeFetchRequest:error:] -[NSManagedObjectContext save:] Regarding the former, note that the deleted objects need not be (and will not be, because they are deleted) included in the fetch results in order to have their attributes hosed. This applies both to explicit deletions performed by -[NSManagedObject deleteObject:], and implicit deletions resulting from the action of a Cascade Delete Rule when a related object is deleted. Because it may be difficult to keep track of when the certain operations are going to be performed, re-inserting deleted objects is not recommended. *** I'll file the above as a bug report next week. Anyone who can further clarify, please reply. For my application, where I am deleting a parent and have children cascade-deleted, I added some extra code to make a collection of children that I don't want delete before deleting their parents, move these children to a temporary foster parent, delete the old parents, then move the children to their new parent. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSManagedObjectContext -insertObject: Cancels Prior Deletion -- BUT!
On May 8, 2009, at 1:00 PM, Jerry Krinock wrote: Conclusion. Here's what I believe to be the missing documentation... *** You can use -insertObject: to cancel a prior deletion, however if certain operations are performed after the deletion and before the restoring -insertObject:, the attributes of the deleted/inserted object will all be set to nil. These certain operations include, but may not be limited to, -[NSManagedObjectContext executeFetchRequest:error:] -[NSManagedObjectContext save:] Regarding the former, note that the deleted objects need not be (and will not be, because they are deleted) included in the fetch results in order to have their attributes hosed. That looks correct and a bug report/documentation enhancement request is reasonable, but note that deleted objects will only have their attributes cleared if: (a) the object is newly inserted (doesn't exist in the persistent store) and (b) no 'undo tracking event (ie user event)' occurs between the creation/insert and subsequent delete. You can trigger the same effect of an undo event boundary by calling processPendingChanges. - adam ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSString to bit pattern
On 08 May 09, at 08:47, Greg Guerin wrote: A string is a sequence of characters. Retrieve each character, determine its bit-pattern, then append that pattern to an NSMutableString. Now you have to figure out how to turn a character into its bit-pattern. So break that down. One extra complication: By Cocoa's standards, a string is not a sequence of bytes: it's a sequence of Unicode codepoints.* To treat a string as a bag of bytes, you will first need to choose a text encoding to treat the text as, then convert it using the NSString dataUsingEncoding: method. If all you're working with is standard ASCII characters, though, this shouldn't be an issue. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSApplication and command line args
On 07 May 09, at 12:36, Brian Arnold wrote: I have recently converted an application which processes command line arguments to call NSApplicationMain when it starts up, and defer command line processing until later in a separate thread. The deferred command line processing still works; however, I am seeing a new behavior where, in some circumstances, NSApplication is passing certain arguments to openFiles, which is undesirable. For example, there may be a command line argument '-logfile /foo/bar', where '/foo/ bar' is also being passed to openFiles. My proposed solution is to detect when an argument is being passed to openFiles during startup (i.e., when the arguments are being processed), and filter it out. I do this by using a boolean flag which is initialized to false and set to true when applicationDidFinishLaunching is called on my delegate. If openFiles is called when sIsRunning is false, I perform this extra check if it's on the command line and ignore it if it is. snip... A much simpler solution would be to preprocess the arguments which you pass to NSApplicationMain. Run through everything in argv, then create a new array of arguments from that with all arguments your application wants to handle removed and pass that to AppKit. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Cancel NSThread - cocoa/mysql database search...
On 08 May 09, at 07:08, spartan g wrote: But the problem I am facing now is, once i sent the query to MySQL through SMySQL framework, I am unable to cancel it. This query takes so much time to return the results and cannot be canceled as far as I understand. Is there any way to cancel this query??? any command or API!!! No. The MySQL C API [1] is synchronous, and provides no method to cancel a query that's in progress. Indeed, the network protocol doesn't either - the only way to stop a query that's running is by using the MySQL KILL command to terminate the connection. If you are ending up with queries that run for 15 to 20 minutes, you probably need to do one or more of the following: 1. Adjust your database schema to make these queries run faster 2. Fetch smaller chunks of data at a time using the LIMIT modifier on queries 3. Change your application so that it performs more efficient queries All of these are really outside the scope of Cocoa development, though. You may have better results asking on a MySQL-specific mailing list or forum. [1]: http://dev.mysql.com/doc/refman/5.1/en/c.html ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: AppleEvents and modal dialogs
On 08.05.2009, at 21:16, James Walker wrote: I have a mostly-Carbon app that runs some Cocoa modal dialogs using - [NSApplication runModalForWindow:]. If an Apple Event (such as 'odoc') arrives while such a dialog is showing, it just gets eaten. I'd like to have it either handled or deferred. I tried creating an NSApplication delegate object, but its application:openFile: method doesn't get called. You probably need to install a kEventAppleEvent Carbon Event Handler as described in CarbonEvents.h's entry on kEventClassAppleEvent / kEventAppleEvent: // If you need to handle this Carbon event yourself, the necessary // steps are: (1) remove the Carbon event from the queue. The // AppleEvent requires some special preparation before it can be // processed, and this preparation only occurs when the event is // dequeued. (2) Use ConvertEventRefToEventRecord to get an // EventRecord from the Carbon event. (3) Call AEProcessAppleEvent // on the EventRecord. It appears that RunApplicationEventLoop() installs a handler for this event, but in mixed Carbon/Cocoa applications, nobody installs this on the Cocoa event loop (just like in WNE-based Applications that call RunAppModalLoop()). I don't remember all the details, but you may have to wait until there actually *is* an event loop to install it on, i.e. do this in - applicationDidFinishLaunching:, or even after each invocation to runAppModalLoopForWindow (but before it returns). Cheers, -- Uli Kusterer The Witnesses of TeachText are everywhere... http://www.zathras.de ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: HFS Format API?
On 08 May 09, at 07:01, iseecolors wrote: Is there a Cocoa/Core Foundation (or ___) API for formatting a Volume? No, largely because formatting a volume is a privileged operation which can't be performed by a userspace application anyway. However, you may want to look into the newfs_hfs and diskutil command-line utilities. And be careful. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Converting NSString to C++ std::string
On Fri, May 8, 2009 at 9:56 AM, Drew Lawson d...@furrfu.com wrote: According to Alex Curylo: On 8-May-09, at 8:55 AM, cocoa-dev-requ...@lists.apple.com wrote: mycppstring = std::string([[myNSTextField stringValue] UTF8String]); But it keeps crashing. What's the recommended way? I have no idea, but it works for me to simply assign it without the constructor. Why, here's an example in the file I'm working on right now, fancy that: The only other gotcha I can think of (because it annoys me) is that std::string does not play nice with null pointers. Is it possible that stringValue returns nil? Hmm, I had one other thought. There are several std::string constructors, depending on the parameter type. In ObjC++, is it unambiguous at compile time that the expression is const char*? Yes. Otherwise, it would be a compile-time error. std::string only has two single-parameter constructors, one takes a (const char*) and one takes a (const std::string), so unless you've defined your own UTF8String method that returns a std::string, none of the other constructors will match. -- Clark S. Cox III clarkc...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSString to bit pattern
On 8 May 2009, at 23:00, Andrew Farmer wrote: On 08 May 09, at 08:47, Greg Guerin wrote: A string is a sequence of characters. Retrieve each character, determine its bit-pattern, then append that pattern to an NSMutableString. Now you have to figure out how to turn a character into its bit-pattern. So break that down. One extra complication: By Cocoa's standards, a string is not a sequence of bytes: it's a sequence of Unicode codepoints.* To treat a string as a bag of bytes, you will first need to choose a text encoding to treat the text as, then convert it using the NSString dataUsingEncoding: method. The UTF encoding that will allow you to treat a string as bag of words (not bytes), where each Unicode codepoint takes exactly the same space, is UTF32. UTF32 is also what C++ expects for its std::wstring type under Unix. I have a framework for Unicode conversion and transformation that internally uses all UTF32 for ease of processing. It is unfortunately not open source at the present time. Robert ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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] Correct way to identify an application, Launch Services, Spaces
On 5/8/09 10:40 AM, Quincey Morris said: OTOH, if your two versions really have a good reason for existing independently (beyond testing and an interim changeover period), then what you probably have is two different apps, and different bundle identifiers would make sense. I've just run into this situation. In my case v2 can open v1 docs, but cannot save that format. Because of this, I think it makes more sense that dbl-clicking a v1 document should open the v1 app, but LS always prefers the newest version of any apps with the same identifier (regardless of LSHandlerRank setting). So if your app changes a lot it makes sense to change identifiers. What a lot is depends. -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Renaming a file repositions icon in Finder
On 5/8/09 2:52 PM, Jim Turner said: It appears that renaming a file will cause the Finder to reposition the icon for the file if it's currently displayed in a icon view somewhere. Is there any way to prevent that from happening? It looks very strange to have icons jump all over the place just because of a rename. Thinking that it might have been the method with which I was renaming the file, I tried NSFileManager's moveItemAtPath:toPath:error:, rename(), and FSRenameUnicode() and all three exhibit the same problem. Many apps exibit this problem and it has driven me and others nuts for years. Do file a(nother) bug. -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSApplication and command line args
On Fri, May 8, 2009 at 6:03 PM, Andrew Farmer andf...@gmail.com wrote: A much simpler solution would be to preprocess the arguments which you pass to NSApplicationMain. Run through everything in argv, then create a new array of arguments from that with all arguments your application wants to handle removed and pass that to AppKit. Why bother? NSProcessInfo already does this for you. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: AppleEvents and modal dialogs
On 5/8/09 12:16 PM, James Walker said: I have a mostly-Carbon app that runs some Cocoa modal dialogs using -[NSApplication runModalForWindow:]. If an Apple Event (such as 'odoc') arrives while such a dialog is showing, it just gets eaten. I'd like to have it either handled or deferred. I tried creating an NSApplication delegate object, but its application:openFile: method doesn't get called. James, I had a similar (but different to be sure) situation. You _might_ find this helpful: http://www.cocoabuilder.com/archive/message/cocoa/2009/3/6/231736 -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSString to bit pattern
Andrew Farmer wrote: One extra complication: By Cocoa's standards, a string is not a sequence of bytes: it's a sequence of Unicode codepoints.* To treat a string as a bag of bytes, you will first need to choose a text encoding to treat the text as, then convert it using the NSString dataUsingEncoding: method. I didn't say a string was a sequence of bytes. I didn't even use the word byte in my reply. This was subtle, but intentional. The interpretation of character was intentionally left as an exercise for the reader to decide. It could mean ASCII character. It could mean UTF8 byte. It could mean Unicode code-point. It depends on what bit-pattern the reader is interested in. However, the interpretation of a character doesn't change the sequence of the elements in the string. They are still arranged in a sequential order, and the process of breaking it down is the same regardless of the coding. -- GG ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSString to bit pattern
On 8 May 2009, at 23:13, Robert Claeson wrote: On 8 May 2009, at 23:00, Andrew Farmer wrote: On 08 May 09, at 08:47, Greg Guerin wrote: A string is a sequence of characters. Retrieve each character, determine its bit-pattern, then append that pattern to an NSMutableString. Now you have to figure out how to turn a character into its bit-pattern. So break that down. One extra complication: By Cocoa's standards, a string is not a sequence of bytes: it's a sequence of Unicode codepoints.* To treat a string as a bag of bytes, you will first need to choose a text encoding to treat the text as, then convert it using the NSString dataUsingEncoding: method. The UTF encoding that will allow you to treat a string as bag of words (not bytes), where each Unicode codepoint takes exactly the same space, is UTF32. It's a mistake to think that way. Even with UTF-32, there is not a one to one correspondence between what the user will think of as a single character (which IIRC in Unicode speak is now referred to as a grapheme cluster) and a Unicode code point. There are plenty of obvious examples, like combining accents, but there are much more complicated examples, for instance in some of the Indic scripts. UTF-32 is largely pointless, actually. UTF-16 (which is what Cocoa uses, and it's also what is used by ICU, the Unicode reference implementation) is never any larger, and is usually only half the size. Moreover, UTF-16 is only twice as large as necessary for U.S. ASCII (not four times like UTF-32), and for non-Latin languages in particular, UTF-16 is often smaller than UTF-8. UTF32 is also what C++ expects for its std::wstring type under Unix. No. C++ doesn't expect any particular encoding for std::wstring, in the same way that C doesn't expect any particular encoding for a wchar_t. It is also worth pointing out that both the C wide character APIs and their C++ brethren are ill suited to Unicode. They were designed under the assumption that one wide character really was one end-user character, and that each unit can be treated separately with no consideration of context. This is true for some of the older wide string encodings that were used historically in Asia, which is what wchar_t et al. were actually designed for. It is *not* the case for any encoding of Unicode. Now it is true that on OS X and Linux, wchar_t is usually used to hold UTF-32, and that is often the case on other platforms also. It is also true that on Windows it normally holds UCS-2 or UTF-16, depending on the APIs you're calling. People would of course immediately say but UTF-16 breaks the spec, so Windows is wrong, and that's true, but so does UTF-32 because of combining characters and the like. Anyway, unless you have special knowledge on a particular platform, the *only* things you can do with the C or C++ wide strings and characters are: - You can use them with the wide string/character APIs. - You can convert them to or from the system's multibyte string format using e.g. wcstombs() or mbstowcs(). Incidentally, you can't portably make assumptions about that format either. - You can pass them to other functions that accept C/C++ wide strings or wide characters. You cannot portably make *any* assumption about the meaning of a wide character in C or C++. For all you know, your code could be running on a Japanese system using some kind of JIS encoding rather than Unicode. I have a framework for Unicode conversion and transformation that internally uses all UTF32 for ease of processing. It is unfortunately not open source at the present time. There is a very comprehensive Open Source Unicode library called ICU. It actually ships as part of Mac OS X, though the headers aren't installed by default. If you can't do what you need with Cocoa or Core Foundation, or you need portability, I strongly recommend that you use ICU. However, before jumping straight for ICU, check out both Cocoa *and* Core Foundation. Chances are that what you need is already in there. Kind regards, Alastair. -- http://alastairs-place.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: NSString to bit pattern
On 8 May 2009, at 10:00, erappy wrote: Hi, I am trying to find way to convert the NSString object into its bit pattern and convert that bit pattern into another NSString object, For Example if I have NSString *origStr = @Hello: NSString * bitPatternoforigStr ; no I want to convert it to the bit pattern if Hello and return an object of type NSString with bit pattern. it should be something like; bitPatternoforigStr = @01011010011000100100110101100101 ; Can someone help me in this. You need to start by deciding what encoding you wish to use for your string. NSString, broadly speaking, works as if it is a container for UTF-16 code units. It isn't always implemented that way under the covers, but you can assume that it behaves that way. If UTF-16 is what you need, you could simply iterate over the string in a loop doing something like this: NSUInteger len = [myString length]; for (NSUInteger n = 0; n len; ++n) { unichar ch = [myString characterAtIndex:n]; // Turn ch (which is 16 bits in length) into binary and append it to your result string } Often you might not want UTF-16 though, and in that case you can use NSString's -dataUsingEncoding: method to convert the string to an NSData containing data in the desired encoding. Then you might loop over it differently, e.g. #include inttypes.h ... NSData *stringData = [myString dataUsingEncoding:NSUTF8StringEncoding]; NSUInteger dataLen = [stringData length]; const uint8_t *bytes = (const uint8_t *)[stringData bytes]; for (NSUInteger n = 0; n dataLen; ++n) { // Turn bytes[n] into binary and append it to your result string } Converting an integer into a binary string is a trivial programming exercise, so you should be able to do that part on your own. Kind regards, Alastair. -- http://alastairs-place.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: Getting the private IP
On 8 May 2009, at 15:46, Mr. Gecko wrote: Hello, I'm trying to find out how to get the private IP address. This is my quick way of finding out. - (NSString *)localIP { NSString *IPAddress = @; struct ifaddrs *myaddrs, *ifa; struct sockaddr_in *s4; int status; char buf[64]; status = getifaddrs(myaddrs); [snip] is there a better way? Depends what you are trying to achieve. It might be better if you could explain what you are doing that needs this information, since there are some alternatives that might be better in some cases. Additionally, you need to be careful because: - There may be more than one active interface with an IP address - There may be more than one IP address for each active interface - Your idea of the right interface to use might not match the user's idea (or the system's idea) Unless you're doing some very low-level networking code, you can usually live without knowing the IP address of the system (to the extent that such a thing actually exists). Kind regards, Alastair. -- http://alastairs-place.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: Getting the private IP
I'm writing a personal application for managing my domains, and I think what I wrote will work well enough for me. But the problem where if it's a self-assigned address does miss with my setup. Because sometimes I'll hock it up via firewire to my server for fast backup. On May 8, 2009, at 6:32 PM, Alastair Houghton wrote: On 8 May 2009, at 15:46, Mr. Gecko wrote: Hello, I'm trying to find out how to get the private IP address. This is my quick way of finding out. - (NSString *)localIP { NSString *IPAddress = @; struct ifaddrs *myaddrs, *ifa; struct sockaddr_in *s4; int status; char buf[64]; status = getifaddrs(myaddrs); [snip] is there a better way? Depends what you are trying to achieve. It might be better if you could explain what you are doing that needs this information, since there are some alternatives that might be better in some cases. Additionally, you need to be careful because: - There may be more than one active interface with an IP address - There may be more than one IP address for each active interface - Your idea of the right interface to use might not match the user's idea (or the system's idea) Unless you're doing some very low-level networking code, you can usually live without knowing the IP address of the system (to the extent that such a thing actually exists). Kind regards, Alastair. -- http://alastairs-place.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
converting a characer to a keycode
i would like to convert a character to its corresponding virtual keycode. the why: i allow users to specify keyboard equivalents for menu items (in a manner similar to xcode key binding preferences). for reasons i don't understand it works better use unshifted characters for the shifted numeric keys. ie, command-shift-1 works for me, whereas command-! (command-exclamation mark) does not. additonally, my app is fully scriptable and i allow the user to specify the keyboard shortcut via an applescript. thus, i would like to convert a script specification of command-exclamation mark to command-shift-1 (command-shift-one). the only way i can think to perform this conversion is to itereate over the virtual key codes 0-127 (with various combinations of shift and option keys) until i find the one that matches the user input character. and while this is certainly doable, it feels awfully clumsy (and potentially slow). is there a better way? thanx, 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: converting a characer to a keycode
ken wrote: the only way i can think to perform this conversion is to itereate over the virtual key codes 0-127 (with various combinations of shift and option keys) until i find the one that matches the user input character. and while this is certainly doable, it feels awfully clumsy (and potentially slow). is there a better way? Create the inverse mapping once, e.g. in an NSDictionary, then use that mapping thereafter, instead of searching repeatedly. This assumes there is an unambiguous inverse mapping, which ain't necessarily so. For example, a keyboard with a numpad has duplicate key legends for all numpad keys. I think these numpad keys have different keycodes than the keys in the main alphanum layout. So given a character like 1 (or *, =, etc.) it's not possible to reverse it to a single unique keycode. -- GG ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSApplication and command line args
On 08 May 09, at 15:48, Kyle Sluder wrote: On Fri, May 8, 2009 at 6:03 PM, Andrew Farmer andf...@gmail.com wrote: A much simpler solution would be to preprocess the arguments which you pass to NSApplicationMain. Run through everything in argv, then create a new array of arguments from that with all arguments your application wants to handle removed and pass that to AppKit. Why bother? NSProcessInfo already does this for you. That doesn't let you hide arguments from AppKit - all it does is let you look at what they were post-launch. As the OP notes, he's got some filename arguments that he doesn't want AppKit to see (because it's treating them as documents to open, which isn't wanted). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: ViewControllers and window nibs
On May 6, 2009, at 3:44 PM, David Scheidt wrote: I've got a Core Data app, using the NSPersistantDocument stuff. There are three basic entity types. There is one, which I'll call MainEntity, which has optional to-many relationships with the other two, which I'll call A and B. In my main window, I have a TableView, which has its columns bound to subclass of NSArrayController (I'm overriding setFilterPredicate, and have some convience methods). In the bottom part of the window, there is an area that shows details of the particular MainEntity that's selected in the table. there is another table column which shows either the AEntities or BEntities that the selected MainEntity has (using an ArrayController bound to MainEntityArrayController.selection. When I have everything in one nib, and use a TabView to control which of the A or B tables is shown, everything works just fine. For various reasons, I want to replace the bottom section of the window with a set of ViewControllers. I'm at a loss trying to figure out how properly get a reference to the MainEntityArrayController. I've put an instance of the ArrayController in my AView.xib, and set the viewControllers mainEntityArrayController outlet in windowControllerDidLoadNib. It gets the right value there, but the change in selection doesn't seem to propagate into the other view. what am I missing?___ For the benefit of the archives: I'm binding to file's owner. (Which, in this case is a ViewController.) It has a reference to the document that the window is associated with, which knows about the array controller. So I use a keypath of self.theDocument.theArrayController.selection.key to get values. I have array controllers in the sub-nibs bound to self .theDocument .theArrayController.selection.relationshipThatPointsAtMySubEntities. Other than being a big pain to type that, this seems to work fine. (I'm getting an error [_NSFaultingMutableSet 0x10828b0 addObserver:forKeyPath:options:context:] is not supported. Key path: @avg.myRating for one of the key paths, but that may be me.) David ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: quick and dirty NSData implosion
On 09/05/2009, at 12:35 AM, jon wrote: @interface BookMark : NSObject You can help yourself out with this type of thing by declaring your classes properly. If you need it to be NSCoding compliant (as you do), then ensure it subscribes to the protocol: @interface BookMark : NSObject NSCoding Then if you forget or don't know how to ensure protocol compliance, the compiler will liberally warn you for all the places you forgot to implement the required methods. If this is gibberish, read up on formal protocols, and NSCoding in particular. http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocProtocols.html http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Protocols/NSCoding_Protocol/Reference/Reference.html --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
Make an attributed string all uppercase without losing attributes?
I have an attributed string. I want to preserve the attributes within the string but set all the actual characters to uppercase, lowercase, etc. According to the docs for NSMutableAttributedString, the - mutableString method returns a mutable string that the receiver tracks changes to in order to preserve attribute runs. However, when I call - setString: or -replaceCharactersInRange:withString: on this, all my attributes are removed. How can I do this without my attributes going AWOL? NSMutableAttributedString* ttd = [[[self textSubstitutor] substitutedStringWithObject:object] mutableCopy]; // capitalize all the text according to the capitalization setting: NSMutableString* mStr = [ttd mutableString]; // Docs: Discussion // The receiver tracks changes to this string and keeps its attribute mappings up to date. NSRange range = NSMakeRange( 0, [mStr length]); switch([self capitalization]) { default: break; case kDKTextCapitalizationUppercase: [mStr replaceCharactersInRange:range withString:[mStr uppercaseString]]; // setString: doesn't work either break; case kDKTextCapitalizationLowercase: [mStr replaceCharactersInRange:range withString:[mStr lowercaseString]]; break; case kDKTextCapitalizationCapitalize: [mStr replaceCharactersInRange:range withString:[mStr capitalizedString]]; break; } tia, --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: NSXMLParser frees itself on error?
On May 8, 2009, at 6:50 , Michael Ash wrote: Begin forwarded message: From: Marcel Weiher marcel.wei...@gmail.com Date: May 7, 2009 10:05:29 PDT And yes, the code that I use explicitly runs the runloop, and it is the code that runs the runloop that both allocates the NSURLConnection and then cleans up after it checks the flag. Perfectly safe, perfectly synchronous. And what about the *a*synchronous case? That *was* the asynchronous case, which I then proceeded to make synchronous. Which means it's synchronous. No, the underlying NSURLConnection calls and callbacks are still the asynchronous and more importantly (to me anyway) incremental ones. How would you handle an asynchronous connection? How many times do I have to repeat my answer? I can't help it if you don't like my solution, but that is *my* solution. Anyway, this whole thing about NSURLConnection and asynchronous 'callbacks' is nothing but a diversion anyway. The original problem is one of releasing an object from a synchronous callback in NSXMLParser, and a whole host of misunderstandings: (1) that NSXMLParser callbacks are asynchronous, which they are not and (b) that there are guarantees that an object autoreleased by the callee is guaranteed to survive a return from the caller, which it is not (c) that autoreleased objects are guaranteed to exist until the end of the current event loop, which they are not etc. As a general note, asynchronous communication has to be handled quite differently, because there isn't a well-defined relationship between the message source and the receiver in terms of call hierarchy. For example, the message-send is done via one of runloop performer methods, then the sender of the message may not be on the call-stack at all at the time the message is received. With NSURLConnection, the situation seems to be a bit different, it appears to be the NSURLConnection itself that handles some of that scheduling and then does a synchronous callback to the delegate. However, because there is actually no reference required, it appears obvious (from the retain/release rules if nothing else), that something else must be holding on to the NSURLConnection while it is doing its asynchronous downloading operation. Certainly that is what I do with async./threaded operations: retain myself at the start, release myself at the end, so I can guarantee (modulo over-release bugs) my own survival while I am running. I tested this and it appears to be true: you can do [[[NSURLConnection alloc] initWithRequest: req delegate: self] release] and it will work just fine. Of course, that is an odd piece of API, so it would probably be better to have a class method that hid the instantiation of the object. Anyway, if you want to have some other solution to NSURLConnection callbacks and lifetime, feel free to implement that and report back, in the meantime I will stick with my solution, which I like because it works and doesn't make any unnecessary and potentially fatal assumptions. Marcel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Hex to NSString or NSData
Hello, I have a string with hex and I want to ether make it into a NSData or NSString. How might I do that. P.S. The only thing I can find is how to make NSString/NSData into hex. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Hex to NSString or NSData
On 2009 May 08, at 20:16, Mr. Gecko wrote: Hello, I have a string with hex and I want to ether make it into a NSData or NSString. How might I do that. -[NSString initWithBytes:length:encoding:] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Hex to NSString or NSData
And how could that make @68656c6c6f into @hello? Thinking this will help you understand what I'm trying to do... On May 8, 2009, at 10:23 PM, Jerry Krinock wrote: On 2009 May 08, at 20:16, Mr. Gecko wrote: Hello, I have a string with hex and I want to ether make it into a NSData or NSString. How might I do that. -[NSString initWithBytes:length:encoding:] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Make an attributed string all uppercase without losing attributes?
On 09/05/2009, at 1:11 PM, Jim Correia wrote: The documentation for -[NSMutableString replaceCharactersInRange:withString:] is perhaps more enlightening. The new characters inherit the attributes of the first replaced character from aRange Processing the string by attribute runs sounds like it should have the effect you are looking for. OK, makes sense. However, it's still not working quite how I'd expected, and there's something odd. Here's my new code: @implementation NSMutableAttributedString (CaseChange) - (void)makeUppercase { NSRange effectiveRange = NSMakeRange( 0, 0 ); NSRange rangeLimit = NSMakeRange( 0, [self length]); NSDictionary* attributes; while( rangeLimit.length 0 ) { attributes = [self attributesAtIndex:rangeLimit.location longestEffectiveRange:effectiveRange inRange:rangeLimit]; NSString* str = [[[self string] substringWithRange:effectiveRange] uppercaseString]; [self replaceCharactersInRange:effectiveRange withString:str]; NSLog(@replacement range: %@, attributes = %@, NSStringFromRange( effectiveRange ), attributes); rangeLimit = NSMakeRange( NSMaxRange( effectiveRange ), [self length] - NSMaxRange( effectiveRange )); } } I have a string which I changed one four-letter word in the middle of to have a number of different font and other traits - bold, italic, larger than normal and underlined. After running the above, the underline attribute is preserved but nothing else. Looking at what is logged, something weird shows up (edited down to just the relevant stuff): 2009-05-09 13:58:16.044 Ortelius[57577:10b] replacement range: {0, 16}, attributes = { NSFont = Helvetica 14.00 pt. P [] (0x1618ad80) fobj=0x00589eb0, spc=3.89; } 2009-05-09 13:58:16.047 Ortelius[57577:10b] replacement range: {16, 4}, attributes = { NSFont = Helvetica 14.00 pt. P [] (0x1618ad80) fobj=0x00589eb0, spc=3.89; NSOriginalFont = Helvetica-BoldOblique 19.00 pt. P [] (0x161b1780) fobj=0x005a1590, spc=5.28; NSUnderline = 1; } 2009-05-09 13:58:16.049 Ortelius[57577:10b] replacement range: {20, 10}, attributes = { NSFont = Helvetica 14.00 pt. P [] (0x1618ad80) fobj=0x00589eb0, spc=3.89; } The ranges detected are correct. The attributes detected are sort of correct, except that the font traits for the modified word in the middle are listed under 'NSOriginalFont', which is not something I can find documented anywhere. These settings are right, but what actually applies is the NSFont setting, which is not right for that range. So what on earth is 'NSOriginalFont' and why is it showing up here? I can see a solution but I'm loath to use something undocumented that I'm not understanding. --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: Hex to NSString or NSData
On 2009 May 08, at 20:34, Mr. Gecko wrote: And how could that make @68656c6c6f into @hello? ? Thinking this will help you understand what I'm trying to do... scanf() ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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