Re: Why is NSString-FSRef so hard?
On Tue, Apr 28, 2009 at 12:21 AM, Erg Consultant erg_consult...@yahoo.com wrote: LSOpenCFURLRef doesn't work either - kLSApplicationNotFoundErr. The nature of the file is the app's exe which is normally inside the MacOS dir. However, all this works perfectly fine if there are no special chars in the path - the exe launches just fine. I find it hard to believe that Apple would issue an API that executes single executable binaries only in the case that they don't have special chars in the path. Because you seem to still think this is Apple's fault, I've created a simple app which demonstrates what you are telling us you are trying to do: https://netfiles.uiuc.edu:443/sbutler1/www/Open%20An%20App.tar.gz The way I tested it is I copied TextEdit to my desktop. Then I renamed it TextEdit™, and went into the app bundle and renamed the executable TextEdit™. Then I typed this into the text box and hit return: /Users/me/Desktop/TextEdit™.app/Contents/MacOS/TextEdit™ Hit launch and TextEdit launched. Ergo, OS X has no problems with special characters in the path. Your issue is in your code. QED. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Second frontmost app?
On 28/04/2009, at 11:02 , Dave DeLong wrote: Is there a way to get the second frontmost app? For example, right now Mail.app is the frontmost, then Safari, because Safari was the active app before I switched to Mail. Is there any sort of API to that tells me that if I were to cmd-tab, that Safari would be the new frontmost app? As far as I'm aware, the only way to do this is to track the front most application with the carbon event kEventClassApplication kEventAppFrontSwitched and remember whatever was the last application. I don't believe you can track application switches from Cocoa directly, but I'd be happy to proven wrong. Enjoy, Peter. -- Run macros from your iPhone with Keyboard Maestro Control! or take a break with Derzle for your iPhone Keyboard Maestro http://www.keyboardmaestro.com/ Macros for your Mac Aragom Space War http://www.stairways.com/iphone/aragom Don't get killed! Derzle http://www.stairways.com/iphone/derzle Enjoy a relaxing puzzle. http://www.stairways.com/ http://download.stairways.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: Why is NSString-FSRef so hard?
I should mention I am using XCode 2.5 under 10.5 so I cannot use the 10.5 SDK nor Obj-C 2.0. Erg From: Stephen J. Butler stephen.but...@gmail.com To: Cocoa-Dev List cocoa-dev@lists.apple.com Sent: Monday, April 27, 2009 11:14:44 PM Subject: Re: Why is NSString-FSRef so hard? On Tue, Apr 28, 2009 at 12:21 AM, Erg Consultant erg_consult...@yahoo.com wrote: LSOpenCFURLRef doesn't work either - kLSApplicationNotFoundErr. The nature of the file is the app's exe which is normally inside the MacOS dir. However, all this works perfectly fine if there are no special chars in the path - the exe launches just fine. I find it hard to believe that Apple would issue an API that executes single executable binaries only in the case that they don't have special chars in the path. Because you seem to still think this is Apple's fault, I've created a simple app which demonstrates what you are telling us you are trying to do: https://netfiles.uiuc.edu:443/sbutler1/www/Open%20An%20App.tar.gz The way I tested it is I copied TextEdit to my desktop. Then I renamed it TextEdit™, and went into the app bundle and renamed the executable TextEdit™. Then I typed this into the text box and hit return: /Users/me/Desktop/TextEdit™.app/Contents/MacOS/TextEdit™ Hit launch and TextEdit launched. Ergo, OS X has no problems with special characters in the path. Your issue is in your code. QED. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/erg_consultant%40yahoo.com This email sent to erg_consult...@yahoo.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Float value change
Hi, I have float values in my iPhone program, when I type in a textfield and print it it shows a little different value than what I have typed, I used printf to see the results. I can't understand why its happening. How can I resolve this. For example textfield.floatValue actual value typed - 44.45 displayed value - 44.45 Can any one help me on some way to avoid this. Thanks -Tharindu ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Why is NSString-FSRef so hard?
On Apr 27, 2009, at 9:14 PM, Erg Consultant wrote: I write the original STL string to a tmp file, then read it back in. The file is encoded in MacRoman. I tried UTF8 with both converting and reinterpreting but if I use UTF8 when I read it back from file, the read returns nil. If I use MacRoman, the string reads back fine, but when I go to convert it to the URL and then the FSSpec, the FSSpec is invalid and cannot be used byLSOpenApplication I think the confusion in your code about encodings is part of the problem: Why is anything MacRoman to begin with at all? Applications these days should be using Unicode throughout if at all possible. Here are the snippets: exePathString = [ NSString stringWithContentsOfFile:kTempQuagmireHackFilePathNSString encoding:NSMacOSRomanStringEncoding error:inError ];// - Works urlRef = [ NSURL fileURLWithPath:exePathString ]; // - Works converted = CFURLGetFSRef( (CFURLRef)urlRef, exeRef ); // - Works It's important to know that this really works -- that CFURLGetFSRef is returning true -- because an FSRef can't refer to a non-existent file. Does it? If you use -[NSData dataWithContentsOfURL:options:error:] to read the contents of your URL, does that succeed? Or if it fails, what does it return for its error output parameter? inAppParams.application = exeRef; // I also zero out the whole block before this. err = LSOpenApplication( inAppParams, outPSN ); // - Fails with -10810 error - Unexpected internal error What else do you have set in inAppParams? Did you specify kLSLaunchDefaults (which *is not* 0) for inAppParams.flags? Do you have appropriate permissions for the application at your ultimate FSRef? -- Chris ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Float value change
Hi, I am trying to store values in a SQLite database and retrieve them, they are currency values, so what is the alternative or solution I will have to look for, I am confused with this. Please is there any work around ?? Regards, -Tharindu ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Why is NSString-FSRef so hard?
Yes, I've verified that everything is correct. I zero'ed the launch param block and set kLSLaunchDefaults. Oddly, I can now get it to work in the built release version (binary) but if I run it from the debugger, LSOpenApplication returns noErr, but if I try to get the pid of the launched, process, it says not found + the binary itself never runs (even though LSOpenApplication returns no err). I assume this has something to do with XCode launching it within its own process. What a headache! Erg From: Chris Hanson c...@me.com To: Erg Consultant erg_consult...@yahoo.com Cc: cocoa-dev@lists.apple.com Sent: Tuesday, April 28, 2009 12:22:38 AM Subject: Re: Why is NSString-FSRef so hard? On Apr 27, 2009, at 9:14 PM, Erg Consultant wrote: I write the original STL string to a tmp file, then read it back in. The file is encoded in MacRoman. I tried UTF8 with both converting and reinterpreting but if I use UTF8 when I read it back from file, the read returns nil. If I use MacRoman, the string reads back fine, but when I go to convert it to the URL and then the FSSpec, the FSSpec is invalid and cannot be used byLSOpenApplication I think the confusion in your code about encodings is part of the problem: Why is anything MacRoman to begin with at all? Applications these days should be using Unicode throughout if at all possible. Here are the snippets: exePathString = [ NSString stringWithContentsOfFile:kTempQuagmireHackFilePathNSString encoding:NSMacOSRomanStringEncoding error:inError ];// - Works urlRef = [ NSURL fileURLWithPath:exePathString ]; // - Works converted = CFURLGetFSRef( (CFURLRef)urlRef, exeRef ); // - Works It's important to know that this really works -- that CFURLGetFSRef is returning true -- because an FSRef can't refer to a non-existent file. Does it? If you use -[NSData dataWithContentsOfURL:options:error:] to read the contents of your URL, does that succeed? Or if it fails, what does it return for its error output parameter? inAppParams.application = exeRef; // I also zero out the whole block before this. err = LSOpenApplication( inAppParams, outPSN ); // - Fails with -10810 error - Unexpected internal error What else do you have set in inAppParams? Did you specify kLSLaunchDefaults (which *is not* 0) for inAppParams.flags? Do you have appropriate permissions for the application at your ultimate FSRef? -- Chris ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Float value change
On 28/04/2009, at 5:24 PM, Tharindu Madushanka wrote: what is the alternative or solution I will have to look for NSDecimal? --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: Second frontmost app?
Le 28 avr. 09 à 05:02, Dave DeLong a écrit : Hey everyone, Is there a way to get the second frontmost app? For example, right now Mail.app is the frontmost, then Safari, because Safari was the active app before I switched to Mail. Is there any sort of API to that tells me that if I were to cmd-tab, that Safari would be the new frontmost app? You can use the ProcessManager API. AFAK, the GetNextProcess() will returns the processes in the order you see them in the cmd+tab panel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Float value change
On 28 Apr 09, at 00:38, Graham Cox wrote: On 28/04/2009, at 5:24 PM, Tharindu Madushanka wrote: what is the alternative or solution I will have to look for NSDecimal? Or integers. Just because a number is represented to the user with a decimal point doesn't mean that the internal representation has to match. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Binding question
Hi, I have an application in which i am trying to display information about the student in a table. The table has 2 columns. One representing the enble/disble in a check box and the other column representing the student column. I have enabled double-click action on the table column. So once i double click on a specific row, i display a sheet and the sheet will display the Name of the student and a table below with 2 columns. First column will represent the subject name and the second column will represent the marke he has scrored in number. i want to use Binding for this application. So I have a model class some thing like this @interface studentmodel { BOOLenabled; NSString Name; NSMutableArray *subjectDetails; } @end The subjectDetails will hold the objects of class @interface deatils { NSString*subjectName; intmarks; } @end For the first table i have used the an array in my controller and this array has been set as content array in the ArrayController object. Now when i double click in need to bind the table in the sheet to the the subjectDetails array. I am not able to figure out how to set the binding for the second table. Any ideas? Thanks Arun KA ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Observing properties which are not objects
Maybe I miss something, but it seems, the standard KVO does not work for properties whose values are non-objects, say int, float etc. How can I effortless accomplish to observe at such properties? For instance: @interface Model { int value; } @property int value; @end @interface Observer { } -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context; @end // Register an observer: Model model* = [[Model alloc] init]; Observer* observer = [[Observer alloc] init]; [model addObserver:observer forKeyPath:@value options:0 context:NULL]; And, btw., how can Model determine whether an observer is added to one of its properties? Thanks in advance Regards Andreas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Dividing NSView to subviews
Hi, For larger views I'm not even getting the blur view, its giving some garbage output... If the view needs to be divided into 20 to 25 images , each image of print rect size. Thanks NareshK On Apr 27, 2009, at 11:42 AM, Peter N Lewis wrote: On 27/04/2009, at 12:16 , Naresh Kongara wrote: in the view drawing code i didn't changed any thing. After preparing the view from which i need to get the images, i just replaced the line NSImage *img = [[[NSImage alloc] initWithData:[view dataWithPDFInsideRect:sourceRect]] autorelease]; with NSImage *img = [view imageFromRect:sourceRect]; The view drawing is same for both the cases, but -(NSImage *)imageFromRect:(NSRect) is giving me a some what blurred image... My guess (and its only a guess because you haven't posted the drawing code) is that the image is being drawn at a different size to the original, and hence scaling. cacheDisplayInRect will return a bit map image which will be blurry if scaled. dataWithPDFInsideRect will (potentially at least) return a PDF image which will scale better. Check your drawing code and ensure it is drawing the image at exactly the same size as the original view bounds. You can also try writing both images to a pdf and tiff and seeing the differences. Enjoy, Peter. -- Run macros from your iPhone with Keyboard Maestro Control! or take a break with Derzle for your iPhone Keyboard Maestro http://www.keyboardmaestro.com/ Macros for your Mac Aragom Space War http://www.stairways.com/iphone/aragom Don't get killed! Derzle http://www.stairways.com/iphone/derzle Enjoy a relaxing puzzle. http://www.stairways.com/ http://download.stairways.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/naresh.kongara%40prithvisolutions.com This email sent to naresh.kong...@prithvisolutions.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
NSPopUpButton update
Hello, i use an NSPopUpButton to display color choices that the user can set in user defaults. There is one view with an NSCollectionView controlled by an NSDictionarycontroller, which populates the dictionary CTColorsDictionary in user defaults with color values (using NSKeyedArchiver) and a corresponding key (@Red, @Green, ...). I then use an NSPopUpButton in another place to let the user choose the color. The popupbutton is bound to another NSDictionaryController which is bound to a shared user defaults controller pointing to values.CTColorsdictionary. To get a small image of the color into the menu I subclassed NSPopUpButton and added these two methods to its implementation: - (void) awakeFromNib { [[self menu] setDelegate:self]; [self menuNeedsUpdate:[self menu]]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(menuNeedsUpdate:) name:NSUserDefaultsDidChangeNotification object:nil]; } - (void)menuNeedsUpdate:(NSMenu *)menu { NSDictionary* colors = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@CTColorsDictionary]; NSImage* image; for (NSMenuItem* item in [self itemArray]) { image = [[[NSImage alloc] initWithSize:NSMakeSize(20, 13)] autorelease]; [image lockFocus]; NSColor* color = [NSKeyedUnarchiver unarchiveObjectWithData:[colors valueForKey:[item title]]]; [color set]; NSRectFill(NSMakeRect(0, 0, 20, 13)); //[image setBackgroundColor:[NSColor blueColor]]; [image unlockFocus]; [item setImage:image]; } [self synchronizeTitleAndSelectedItem]; [self display]; } This works normally. The problem is now: When I change a color in user defaults, I can see (for a tenth of a second or so) that the color image of the currently selected item in the popup is redrawn, but then the title gets overwritten by another method, which ignores the image setting of my menu items and just displays the text. Does anybody have an idea which method is doing this, and how I could override it? When I click once on the popupbutton everything is ok again and the color image reappears. ALEXander. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Observing properties which are not objects
On 28/04/2009, at 8:23 PM, Andreas Grosam wrote: Maybe I miss something, but it seems, the standard KVO does not work for properties whose values are non-objects, say int, float etc. How can I effortless accomplish to observe at such properties? Scalar properties (int, float, etc) are automatically wrapped in a NSValue/NSNumber instance when using KVC and KVO. And, btw., how can Model determine whether an observer is added to one of its properties? In general, it can't. And in general, it doesn't need to know. If you follow the rules you shouldn't need to know. It does take a little bit of grokking at first, because when I first approached KVO that was my first question to myself also. Hence my first design sucked. Later, I realised that a good design doesn't require this knowledge things got a whole lot easier, particularly when de-observing (if that's the right term). --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
Finder Sidebar Shared Items
Hello, I'm trying to find out how to get the list of items in the Shared group of the Finder sidebar. * I see that using the LSSharedFileList API along with the kLSSharedFileListRecentServerItems constant I can fetch the list of Servers from the Recent Items menu * The ~/Library/Preferences/com.apple.sidebarlists.plist file has some ofdata, but doesn't appear to have the Shared items Does anyone know where this list is stored or how it can be accessed programmatically? Thanks, Steve -- Steven Huey Software - http://www.stevenhuey.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
soft line breaks in NSLayoutManager
Hi, I have a formatted text in an NSTextStorage which I would like to draw. I also have an array of character locations where to break the text into lines. Is there a way to add soft line breaks to the layout without modifying the unicode string (inserting line break characters)? In the ATSU-world I used ATSUSetSoftLineBreak, but it is not supported in 64-bit. Thanks for any help Geza ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: URL Parsing
Also have a look at: http://trac.adiumx.com/wiki/AutoHyperlinksFramework On 28 Apr 2009, at 05:05, Mr. Gecko wrote: One thing I can try is to put every word in a array, go through them, see if they contain http or https in the beginning, if so add a href=URLURL/a to it. On Apr 27, 2009, at 10:01 PM, Ken Thomases wrote: On Apr 27, 2009, at 8:57 PM, Mr. Gecko wrote: Hello, I'm trying to parse out urls in a string and make them into html links so when I put the string into webview people can click them. Any help? I haven't done any work with WebKit, but NSTextView and NSAttributedString have facilities for URL detection, so I wouldn't be surprised to find that WebView does, too. See -[NSAttributedString URLAtIndex:effectiveRange:] and - [NSTextView setAutomaticLinkDetectionEnabled:]. Cheers, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net This email sent to cocoa...@mikeabdullah.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Scheduling application
On 2009 Apr 28, at 00:35, Mahaboob wrote: The folder permission of LaunchDaemons is read only. So I can't write the plist file into this folder programmatically. How can I do it? First, read or re-read Apple's TN2083 and verify that your ^really^ need to create a system daemon instead of a per-user agent. http://developer.apple.com/technotes/tn2005/tn2083.html If you ^really^ need to make a system daemon, then you must use Authorization Services to add that file programatically. Reserve a week or two in your schedule and begin by searching the web for Apple's BetterAuthorizationSample. Discussion of BetterAuthorizationSample should be sent to the group apple-c...@lists.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
Thread safety
The docs say that: Note that although NSSerializer, NSArchiver, NSCoder, and NSEnumerator objects are themselves thread-safe, they are listed here because it is not safe to change the data objects wrapped by them while they are in use. For example, in the case of an archiver, it is not safe to change the object graph being archived. For an enumerator, it is not safe for any thread to change the enumerated collection. NSUnarchiver is not listed, but based on the above is the following ok? NSArray* localArray; localArray = [NSUnarchiver unarchiveObjectWithData:localData]; if (localArray) { NSEnumerator* enumerator = [localArray objectEnumerator]; NSDictionary*dict; while (dict = [enumerator nextObject]) { if ([[dict objectForKey:@myVal] unsignedShortValue] == kSomeValue) { // do things that are thread safe } } } Everything above is read only, so I don't think I am changing data objects wrapped by them while they are in use. Certainly this is true for NSEnumerator, but not sure about the unwritten safety of NSUnarchiver. The code is working in a thread, and has not crashed. 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: C string constant-NSString constant without defining twice?
It's possible it doesn't always work, but it worked for me when I tried it... Dave On Apr 28, 2009, at 9:18 AM, Erik Buck wrote: I haven't tried, but I don't think the following works because of the way the pre-processor inserts spaces: #define kConstCString This is a const c string #define kConstNSString @kConstCString Don't hard code paths! Use NSHomeDirectory() or NSTemporaryDirectory() or NSSearchPathForDirectoriesInDomains(). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Why is NSString-FSRef so hard?
On Tue, Apr 28, 2009 at 1:13 AM, Erg Consultant erg_consult...@yahoo.com wrote: Apple's doc's specifically say to stay away from using the CString routines which require encodings. So now the encoding issue goes away. The problem is LSOpenApplication() does not like the FSRef I pass it which gets created from the path NSString-CFURL-FSRef. They state the opposite. They say to stay away from the ones which do NOT require encodings. That's because the ones without encodings use the system encoding which is not guaranteed to be anything useful. The ones with encodings require you to specify them yourself and are therefore just fine. 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: C string constant-NSString constant without defining twice?
On Tue, Apr 28, 2009 at 10:18 AM, Erik Buck erik.b...@sbcglobal.net wrote: I haven't tried, but I don't think the following works because of the way the pre-processor inserts spaces: #define kConstCString This is a const c string #define kConstNSString @kConstCString Well, if that doesn't work (and I didn't test it) this should: #define kConstCString This is a const c string #define kConstNSString ((NSString*)CFSTR( kConstCString )) Don't hard code paths! Use NSHomeDirectory() or NSTemporaryDirectory() or NSSearchPathForDirectoriesInDomains(). Not only that, but hardcoding filenames in tmp directories is generally considered a security bug. You should be using mktemp or one of its ilk. Not sure if there's a Cocoa API for that. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Second frontmost app?
Well, I got this working with a timer that just keeps track of the activeApplication and the previously activeApplication, but I'm intrigued by this approach, so I'd like to see if this works, too. Here's what I've got: ProcessSerialNumber psn; OSErr result = GetCurrentProcess(psn); if (result != 0) { NSLog(@Error for current process: %d, result); return; } result = GetNextProcess(psn); if (result != 0) { NSLog(@Error for next process: %d, result); return; } However, when I run that, I always get: Error for next process: -600 (-600 = No eligible process with specified process serial number.) Any ideas? Thanks, Dave On Apr 28, 2009, at 1:44 AM, Jean-Daniel Dupas wrote: You can use the ProcessManager API. AFAK, the GetNextProcess() will returns the processes in the order you see them in the cmd+tab panel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: URL Parsing
Have a look at how it works; very simple to write your own version using their scanner that generates HTML. In fact I have a rough implementation as a patch sitting in their tracker system somewhere. On 28 Apr 2009, at 16:34, Mr. Gecko wrote: Can't really do that because I'm needing it to be in html format not attributed string. On Apr 28, 2009, at 7:15 AM, Mike Abdullah wrote: Also have a look at: http://trac.adiumx.com/wiki/AutoHyperlinksFramework On 28 Apr 2009, at 05:05, Mr. Gecko wrote: One thing I can try is to put every word in a array, go through them, see if they contain http or https in the beginning, if so add a href=URLURL/a to it. On Apr 27, 2009, at 10:01 PM, Ken Thomases wrote: On Apr 27, 2009, at 8:57 PM, Mr. Gecko wrote: Hello, I'm trying to parse out urls in a string and make them into html links so when I put the string into webview people can click them. Any help? I haven't done any work with WebKit, but NSTextView and NSAttributedString have facilities for URL detection, so I wouldn't be surprised to find that WebView does, too. See -[NSAttributedString URLAtIndex:effectiveRange:] and - [NSTextView setAutomaticLinkDetectionEnabled:]. Cheers, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net This email sent to cocoa...@mikeabdullah.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Why is NSString-FSRef so hard?
On Mon, Apr 27, 2009 at 10:13 PM, Erg Consultant erg_consult...@yahoo.com wrote: Apple's doc's specifically say to stay away from using the CString routines which require encodings. Where do they say that? -- 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
NSMetadataQueryDidUpdateNotification problem with volumes
I've setup a NSMetaDataQuery to search for particular file types. I've set the search scope to NSMetadataQueryLocalComputerScope. The initial search phase works correctly. The query returns all of the expected files on all of the local volumes. Now if I add a file to the root volume I get the NSMetadataQueryDidUpdateNotification notification as expected. But adding a file to any of the other local volume does not seem to fire the notification. I know that spotlight is indexing the files because a similar search through the finder will return the newly added files. Also if I restart my application the new files will be found in the initial search phase. Is this a bug or am I missing something? -- Eddie Aguirre ed...@markzware.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
Cookie accept policy
Hi list! I've tried to establish some http communication with the help of the URL loading system. I had to discover that the cookie accept policy setting of the shared cookie storage effects all applications using the URL loading system. My application needs to accept cookies at all times. So what I don't want to do is to change the accept policy setting temporarily. This would mean a security risk for all other apps. Another way would be not to use the automatic cookie handling and to handle the cookies myself which is undesirable because of all the effort it would take to implement. Is there another way to change the cookie accept setting only for my application/process to accept all cookies? Best Regards Kay ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 Display Names
Are these names only accessible from private frameworks or is there an AppKit or CoreGraphics API I have yet to stumble across that maps the display unit number or display ID to a localized (or not) display name? The answer is in I/O Kit: #import IOKit/graphics/IOGraphicsLib.h #import IOKit/graphics/IOGraphicsTypes.h NSString* screenNameForDisplayID(CGDirectDisplayID displayID) { NSDictionary *deviceFullDescription = (NSDictionary *) IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID), kNilOptions ); if (deviceFullDescription == nil) { return nil; } NSDictionary *localizedNames = [deviceFullDescription objectForKey :@kDisplayProductName]; if ([localizedNames count] 1) { return nil; } NSString *languageKey = nil; for (NSString *preferredLanguage in [NSLocale preferredLanguages]) { for (NSString *localeIdentifier in [localizedNames allKeys]) { if ([[[NSLocale componentsFromLocaleIdentifier :preferredLanguage] objectForKey:NSLocaleLanguageCode] isEqualToString:[[ NSLocale componentsFromLocaleIdentifier:localeIdentifier] objectForKey: NSLocaleLanguageCode]]) { languageKey = localeIdentifier; goto exit; } } } exit: return [localizedNames objectForKey:languageKey ? languageKey : [[localizedNames allKeys] objectAtIndex:0]]; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Bindings confusion
Hi, I'm running into a binding issue is my main application so I wrote a small test app to try to track down the problem: primarily that I cannot get the UI to update appropriately when it is configured to observe my model objects via bindings. // AppDelegate.h @class ModelObject; @interface AppDelegate : NSObject { ModelObject *modelObject; int _someProperty; } @property int someProperty; - (IBAction)doSomething:(id)sender; @end // AppDelegate.m @implementation AppDelegate @synthesize someProperty = _someProperty; - (void)awakeFromNib { modelObject = [[ModelObject alloc] init]; } - (void)dealloc { [modelObject release]; [super dealloc]; } - (void)doSomething:(id)sender { [modelObject changeValue]; } // ModelObject.h @interface ModelObject : NSObject { int _someProperty; } @property int someProperty; - (void)changeValue; @end // ModelObject.m @implementation ModelObject @synthesize someProperty = _someProperty; - (id)init { if (nil == (self = [super init])) return nil; self.someProperty = 10; return self; } - (void)changeValue { self.someProperty = (_someProperty == 10) ? 5 : 10; } @end In my xib I I have an object that represents my AppDelegate. I bind the value of an NSLabel to the AppDelegate's modelObject.someProperty keypatch. But no matter what I do the value is never updated in the UI. Do you see something obvious that I am missing? This is a retain/release Cocoa app running on 10.5.6 using Xcode 3.1.2. Any guidance would be appreciated, CxT ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Group Identity Programming
Hi all, First of all, I apologize because I have only been developing Cocoa for a few months and I'm learning as I go. Hopefully I'm not making some newbie mistake. I am trying to write a program that, among other things, generates a list of user and group identities using the identity picker and then checks to see if the logged-on user matches any user identity or is a member of any group. I can do the first task, but I am having trouble with the group identity part. My main issue, I believe, is that I cannot get to the group-specific attributes (gid and members). I have tried the function identityWithName:authority: two different ways: CBGroupIdentity *groupID = [CBGroupIdentity identityWithName:[tmpArray objectAtIndex:i] authority:[CBIdentityAuthority defaultIdentityAuthority]]; CBGroupIdentity *groupID = [CBIdentity identityWithName:[tmpArray objectAtIndex:i] authority:[CBIdentityAuthority defaultIdentityAuthority]]; The tmpArray objectAtIndex:i is an NSString representation of the group's name, but I have also tried it with the UUID. This gives me the warning initilization from distinct Objective-C type. When I try to call members or posixGID on either of these, the program hangs. Also, I have tried to just circumvent creating a group identity and get to the heart of the matter by doing the following, using a test group I generated myself on the local machine (the other groups were made by someone else and are not local groups): NSString *user = NSUserName(); CBIdentity *localIdentity = [CBIdentity identityWithName:user authority:[CBIdentityAuthority defaultIdentityAuthority]]; [localIdentity isMemberOfGroup:[CBGroupIdentity identityWithName:@test_group authority:[CBIdentityAuthority localIdentityAuthority]]]; This hangs the program. The third thing I tried is getting the gid using: gid_t curGroupID = getgid(); OR int curGroupID = getgid(); CBGroupIdentity *groupIdentity = [CBGroupIdentity groupIdentityWithPosixGID:curGroupID authority:[CBIdentityAuthority defaultIdentityAuthority]]; When I try to show the gid using NSLog, it hangs the program. When I show the groupIdentity object, it returns (null). I have both the Collaboration and Foundation frameworks imported. If anyone can help me with this, I'd really appreciate it. This is driving me insane. Thanks, Jessica ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
NSArrayController: Objects with empty strings
Hi list, I am new to the cocoa development. I have some question to NSArrayController I add an object to the controller array like this: CODE ## NSMutableDictionary *theDicRow = [NSMutableDictionary dictionaryWithObjectsAndKeys: @Text A, @colA, @Text B, @colB, nil ]; [myArrayController addObject:theDicRow]; CODE ## This works great and do its job. I can call the object from the content an get the log result like this: CODE ## [2355:10b] ( { colA = Text A; colB = Text B; } ) CODE ## Well, this is okay. If I do this: CODE ## NSMutableDictionary *theDicRow = [NSMutableDictionary dictionaryWithObjectsAndKeys: @Text A, @colA, @, @colB, nil ]; CODE ## The result is: CODE ## [2355:10b] ( { colA = Text A; } ) CODE ## But I wanna have the empty string back. So it seems, that the empty string is converted to nill and the controller is killing them out. How can I change this reaction with empty strings? I need this @ Strings. Thank you for information! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Storing a table view in user defaults
I'm a relative newb when it comes to cocoa programming, but I've been trying to finish of a project and put it out there so I can get some feedback and continue to get better. My problem is that I have a table view that's bound to an array controller backed by user defaults in IB. Adding a single new row works fine, but if I add any more, the data from the previous rows gets wiped out, but the actual rows get preserved. Further more, if I create a row and exit/relaunch the rows are persisted, but the data is not. If feel like I'm missing some important detail, but I can't figure out what. Any help is appreciated. Thanks. -- Ryan Carmelo Briones ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Cookie accept policy
On Apr 28, 2009, at 12:57 AM, Kay Jurkuhn wrote: Is there another way to change the cookie accept setting only for my application/process to accept all cookies? No. As you discovered, the cookie storage settings are global and can't be changed on a per-application basis. Nick Zitzmann http://www.chronosnet.com/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: C string constant-NSString constant without defining twice?
On 28/04/2009 16:51, Stephen J. Butler stephen.but...@gmail.com wrote: On Tue, Apr 28, 2009 at 10:18 AM, Erik Buck erik.b...@sbcglobal.net wrote: Don't hard code paths! Use NSHomeDirectory() or NSTemporaryDirectory() or NSSearchPathForDirectoriesInDomains(). Not only that, but hardcoding filenames in tmp directories is generally considered a security bug. You should be using mktemp or one of its ilk. Not sure if there's a Cocoa API for that. It's not only a security bug but a buggy bug. If you see what I mean :-). What happens if two users are fast-user-switching on the same box? Both apps are using the same temporary data... Cheers, Graham. -- Graham Lee Senior Mac Software Engineer tel: +44 1235 540266 SOPHOS - simply secure Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
How to make NSSplitView not dragable
Hi All, I have a horizontal NSSplitView, I want the splitter bar should remain in a fixed postion and user should not be able to change size of upper subview or lower subview by dragging it. Note: Split bar should be visible but not be drag able. Thanks, Ashish DISCLAIMER == This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Bindings confusion
On Apr 28, 2009, at 06:04, Simon Raisin wrote: I'm running into a binding issue is my main application so I wrote a small test app to try to track down the problem: primarily that I cannot get the UI to update appropriately when it is configured to observe my model objects via bindings. ... - (void)awakeFromNib { modelObject = [[ModelObject alloc] init]; } ... In my xib I I have an object that represents my AppDelegate. I bind the value of an NSLabel to the AppDelegate's modelObject.someProperty keypatch. But no matter what I do the value is never updated in the UI. Do you see something obvious that I am missing? By binding to modelObject.someProperty, you're asserting that modelObject is a property of your app delegate, but you haven't implemented it as such. Because (presumably) you've left +[AppDelegate accessInstanceVariablesDirectly] at its default of YES, your instance variable 'modelObject' *behaves like* a property, but things break down in awakeFromNib because modelObject isn't being updated KVO- compliantly there. Try writing @property/@synthesize for your modelObject, then initialize it with: self.modelObject = [[ModelObject alloc] init]; in awakeFromNib. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Second frontmost app?
Don't bother with that. I did a try, and it look like the Process Manager order has nothing to do with the cmd + tab order. it returns -600, probably because psn is the last process in the Process Manager list. Sorry for the noise. Le 28 avr. 09 à 17:55, Dave DeLong a écrit : Well, I got this working with a timer that just keeps track of the activeApplication and the previously activeApplication, but I'm intrigued by this approach, so I'd like to see if this works, too. Here's what I've got: ProcessSerialNumber psn; OSErr result = GetCurrentProcess(psn); if (result != 0) { NSLog(@Error for current process: %d, result); return; } result = GetNextProcess(psn); if (result != 0) { NSLog(@Error for next process: %d, result); return; } However, when I run that, I always get: Error for next process: -600 (-600 = No eligible process with specified process serial number.) Any ideas? Thanks, Dave On Apr 28, 2009, at 1:44 AM, Jean-Daniel Dupas wrote: You can use the ProcessManager API. AFAK, the GetNextProcess() will returns the processes in the order you see them in the cmd+tab panel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org This email sent to devli...@shadowlab.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: Why is NSString-FSRef so hard?
Le 28 avr. 09 à 17:47, Michael Ash a écrit : On Tue, Apr 28, 2009 at 1:13 AM, Erg Consultant erg_consult...@yahoo.com wrote: Apple's doc's specifically say to stay away from using the CString routines which require encodings. So now the encoding issue goes away. The problem is LSOpenApplication() does not like the FSRef I pass it which gets created from the path NSString- CFURL-FSRef. They state the opposite. They say to stay away from the ones which do NOT require encodings. That's because the ones without encodings use the system encoding which is not guaranteed to be anything useful. The ones with encodings require you to specify them yourself and are therefore just fine. And to add a word about your LS issue, it's because to launch an app, you should create a ref on the bundle, not on the executable. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Second frontmost app?
Sounds good. For documenting purposes, here's what I did to get this working: In the appropriate class, I have an NSMutableArray called activeApps and a timer called appTimer. The timer is scheduled to fire every 0.5 seconds. When it fires, it gets the activeApplication dictionary from NSWorkspace, and compares that to the 0th element in activeApps. If they're different, then the new dictionary is inserted at index 0, and the last element (if the count is greater than 2) is removed. Whenever I need the second frontmost app, I just get the dictionary at index 1 in activeApps. Dave On Apr 28, 2009, at 10:57 AM, Jean-Daniel Dupas wrote: Don't bother with that. I did a try, and it look like the Process Manager order has nothing to do with the cmd + tab order. it returns -600, probably because psn is the last process in the Process Manager list. Sorry for the noise. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Second frontmost app?
You're starting off with GetCurrentProcess, which returns the process number of your application; have you tried GetFrontProcess, which returns the front process? This will not be your application if you're in the background. On 04/28/2009 9:57 AM, Jean-Daniel Dupas devli...@shadowlab.org wrote: Don't bother with that. I did a try, and it look like the Process Manager order has nothing to do with the cmd + tab order. it returns -600, probably because psn is the last process in the Process Manager list. Sorry for the noise. Le 28 avr. 09 à 17:55, Dave DeLong a écrit : Well, I got this working with a timer that just keeps track of the activeApplication and the previously activeApplication, but I'm intrigued by this approach, so I'd like to see if this works, too. Here's what I've got: ProcessSerialNumber psn; OSErr result = GetCurrentProcess(psn); if (result != 0) { NSLog(@Error for current process: %d, result); return; } result = GetNextProcess(psn); if (result != 0) { NSLog(@Error for next process: %d, result); return; } However, when I run that, I always get: Error for next process: -600 (-600 = No eligible process with specified process serial number.) Any ideas? Thanks, Dave On Apr 28, 2009, at 1:44 AM, Jean-Daniel Dupas wrote: You can use the ProcessManager API. AFAK, the GetNextProcess() will returns the processes in the order you see them in the cmd+tab panel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Second frontmost app?
Yes, I tried both, and got the same result each time (-600 when trying to get the next process). Dave On Apr 28, 2009, at 11:06 AM, Gary L. Wade wrote: You're starting off with GetCurrentProcess, which returns the process number of your application; have you tried GetFrontProcess, which returns the front process? This will not be your application if you're in the background. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 'launchAppWithBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifier:'???
Ken. When not providing the descriptor, it would launch the app and print the untitled document that was automatically opened. Tried it with Comic Life and Microsoft Word, among others. Of course, I'm running 10.5.6 here. With FSRef-based AE descriptor, it opens the right document. I guess that if I wanted to optimize, I would need to pass a list-based AE descriptor with a bunch of FSRef-based AE descriptors and call that method only once, but I have other pressing needs right now :-) -Laurent. -- Laurent Daudelin AIM/iChat/Skype:LaurentDaudelin http://nemesys.dyndns.org Logiciels Nemesys Software laurent.daude...@verizon.net Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries On Apr 27, 2009, at 19:30 , Ken Thomases wrote: On Apr 27, 2009, at 3:22 PM, Laurent Daudelin wrote: That did work but I found that I had to keep providing the descriptor for some reason. _What_ did work? What specifically did you try? You had to keep providing the descriptor or else... what? What happened (or didn't happen) differently than you expected? Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Second frontmost app?
To iterate over all apps, you should pass { 0, kNoProcess } in the first GetNextProcess call. But as I mention, the result list is not usefull top solve this issue. That said, using Carbon event to track application switching as suggested sooner would be a cleaner and more reliable way to do this than polling using a Timer. IIRC, the API required to do this is available on 64bits (as there is no replacement yet). And it's not very difficult: == #include Carbon/Carbon.h #if __LP64__ // workaround missing declaration extern EventTargetRef GetApplicationEventTarget(void); #endif static OSStatus _SDProcessManagerEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) { if (GetEventClass(inEvent) == kEventClassApplication) { ByteCount size; EventParamType type; ProcessSerialNumber psn; MyClass *handler = (MyClass *)inUserData; verify_noerr(GetEventParameter(inEvent, kEventParamProcessID, typeProcessSerialNumber, type, sizeof(psn), size, psn)); switch (GetEventKind(inEvent)) { case kEventAppFrontSwitched: [handler frontApplicationDidChange:psn]; return noErr; } } return eventNotHandledErr; } == And in your initialization code: == EventTypeSpec eventTypes[] = { { kEventClassApplication, kEventAppFrontSwitched }, }; InstallApplicationEventHandler(_SDProcessManagerEvent, GetEventTypeCount(eventTypes), eventTypes, self, NULL); == Le 28 avr. 09 à 19:06, Gary L. Wade a écrit : You're starting off with GetCurrentProcess, which returns the process number of your application; have you tried GetFrontProcess, which returns the front process? This will not be your application if you're in the background. On 04/28/2009 9:57 AM, Jean-Daniel Dupas devli...@shadowlab.org wrote: Don't bother with that. I did a try, and it look like the Process Manager order has nothing to do with the cmd + tab order. it returns -600, probably because psn is the last process in the Process Manager list. Sorry for the noise. Le 28 avr. 09 à 17:55, Dave DeLong a écrit : Well, I got this working with a timer that just keeps track of the activeApplication and the previously activeApplication, but I'm intrigued by this approach, so I'd like to see if this works, too. Here's what I've got: ProcessSerialNumber psn; OSErr result = GetCurrentProcess(psn); if (result != 0) { NSLog(@Error for current process: %d, result); return; } result = GetNextProcess(psn); if (result != 0) { NSLog(@Error for next process: %d, result); return; } However, when I run that, I always get: Error for next process: -600 (-600 = No eligible process with specified process serial number.) Any ideas? Thanks, Dave On Apr 28, 2009, at 1:44 AM, Jean-Daniel Dupas wrote: You can use the ProcessManager API. AFAK, the GetNextProcess() will returns the processes in the order you see them in the cmd+tab panel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSDateFormatter for ISO8601
On Mon, 2009/04/27, Martijn van Exel mve...@gmail.com wrote: Unrelated: one of the XML attributes that needed parsing was a ISO8601 style date string, for which neither NSDate nor NSDateFormatter curiously does not seem to provide a parser. ? Of course, it will parse ISO dates. You just need to give it the format... off the top of my head something like %Y-%m-%dT%H:%M%:s ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: click in NSButtonCell in NSTableView without selecting table row? [SOLVED]
Thanks, Corbin - to summarize for posterity, the implementation of - (BOOL)outlineView:(NSOutlineView *)ov shouldSelectItem:(id)item is using -clickedColumn and -clickedRow to determine the location of the click, and not selecting the row (returning NO) if the cell in that location is an enabled NSButtonCell. I had originally discarded this approach because of this line in the documentation for -clickedColumn: The return value of this method is meaningful only in the target¹s implementation of the action or double-action method. Apparently this statement is no longer true. Thanks for the help! Dan On 4/27/09 6:17 PM, Corbin Dunn corb...@apple.com wrote: On Apr 27, 2009, at 1:43 PM, Dan Rowley wrote: Hello - I've done multiple searches and seen this topic discussed, but none with a solution that doesn't feel like a hack. I have an NSTableView, and one column that contains an NSButtonCell. I would like the user to be able to interact with this cell without the selection in the table changing. In the documentation for - tableView:shouldTrackCell:forTableColumn:row: , it says For example, this allows you to have an NSButtonCell in a table which does not change the selection, but can still be clicked on and tracked, yet I'm not exactly sure how to actually achieve this end. I return YES from the delegate method, then indeed my button works correctly (the data source gets the expected setObjectValue message), but the selection of the table also changes. The obvious first solution is to override tableView:shouldSelectRow:, yet this gets sent BEFORE shouldTrackCell, so I'm not really sure where to go from here. Do I have to gawk at the current mouse event in shouldSelectRow: and return NO if it appears that the mouse went down in the button cell? This feels harder than it ought to be. Am I missing something painfully obvious? the DragNDropOutlineView example does this on Leopard. If after checking it out you still have questions, then please repost. corbin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Storing a table view in user defaults
On 2009 Apr 28, at 08:04, Ryan Briones wrote: My problem is that I have a table view that's bound to an array controller backed by user defaults in IB. I don't know what backed by means. The 'content' binding of your array controller should be bound to an NSUserDefaults object (labelled Shared Defaults by Interface Builder) with Controller Key = 'values' Model Key Path = keyToYourArrayInRootOfUserDefaults. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: C string constant-NSString constant without defining twice?
On Apr 28, 2009, at 9:39 AM, Graham Lee wrote: On 28/04/2009 16:51, Stephen J. Butler stephen.but...@gmail.com wrote: On Tue, Apr 28, 2009 at 10:18 AM, Erik Buck erik.b...@sbcglobal.net wrote: Don't hard code paths! Use NSHomeDirectory() or NSTemporaryDirectory() or NSSearchPathForDirectoriesInDomains(). Not only that, but hardcoding filenames in tmp directories is generally considered a security bug. You should be using mktemp or one of its ilk. Not sure if there's a Cocoa API for that. It's not only a security bug but a buggy bug. If you see what I mean :-). What happens if two users are fast-user-switching on the same box? Both apps are using the same temporary data... The preferred solution is NSTemporaryDirectory(). As of Leopard it returns a local access-controlled per-user directory. This avoids security holes and user collisions. Recommended practice is to create a subdirectory there named after your bundle identifier (i.e. com.yourcompany.yourapp), in order to avoid collisions with other apps and frameworks. In Tiger and earlier, NSTemporaryDirectory() returns /tmp. You'll still need all of the traditional safety and security checks there. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: click in NSButtonCell in NSTableView without selecting table row? [SOLVED]
is using -clickedColumn and -clickedRow to determine the location of the click, and not selecting the row (returning NO) if the cell in that location is an enabled NSButtonCell. I had originally discarded this approach because of this line in the documentation for -clickedColumn: The return value of this method is meaningful only in the target’s implementation of the action or double-action method. Ah -- can you please log a documentation bug using the bottom of the doc page? Feel free to cite me and/or the demo. corbin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Group Identity Programming
On Apr 28, 2009, at 8:58 AM, Jessica Billings wrote: I am trying to write a program that, among other things, generates a list of user and group identities using the identity picker and then checks to see if the logged-on user matches any user identity or is a member of any group. I can do the first task, but I am having trouble with the group identity part. My main issue, I believe, is that I cannot get to the group-specific attributes (gid and members). I have tried the function identityWithName:authority: two different ways: CBGroupIdentity *groupID = [CBGroupIdentity identityWithName:[tmpArray objectAtIndex:i] authority:[CBIdentityAuthority defaultIdentityAuthority]]; CBGroupIdentity *groupID = [CBIdentity identityWithName:[tmpArray objectAtIndex:i] authority:[CBIdentityAuthority defaultIdentityAuthority]]; Why do think this would work at all? It is not consistent with the documentation. -identityWithName:authority: returns a CBIdentity object, not a CBGroupIdentity object. So of course it will not respond to CBGroupIdentity instance methods. The tmpArray objectAtIndex:i is an NSString representation of the group's name, but I have also tried it with the UUID. This gives me the warning initilization from distinct Objective-C type. When I try to call members or posixGID on either of these, the program hangs. This should have been the first clue that you're doing something wrong. Also, I have tried to just circumvent creating a group identity and get to the heart of the matter by doing the following, using a test group I generated myself on the local machine (the other groups were made by someone else and are not local groups): NSString *user = NSUserName(); CBIdentity *localIdentity = [CBIdentity identityWithName:user authority:[CBIdentityAuthority defaultIdentityAuthority]]; [localIdentity isMemberOfGroup:[CBGroupIdentity identityWithName:@test_group authority:[CBIdentityAuthority localIdentityAuthority]]]; Except that you aren't circumventing anything, you are juts doing the same wrong thing: [CBGroupIdentity identityWithName:@test_groupauthority:[CBIdentityAuthority localIdentityAuthority]]. You cannot get a group identity this way. The third thing I tried is getting the gid using: gid_t curGroupID = getgid(); OR int curGroupID = getgid(); CBGroupIdentity *groupIdentity = [CBGroupIdentity groupIdentityWithPosixGID:curGroupID authority:[CBIdentityAuthority defaultIdentityAuthority]]; When I try to show the gid using NSLog, it hangs the program. When I show the groupIdentity object, it returns (null). The above is better. What does the debugger show for curGroupID? There is no reason to hang on NSLog if for curGroupID, as it is really juts an unsigned int. What is the NSLog code you are using? Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSArrayController: Objects with empty strings
On Apr 28, 2009, at 8:59 AM, MyApps wrote: First off, a suggestion: please don't delimit code sections like you do. In fact, you don't need any delimiters other than whitespace (as you can see with the edited text below). And you can see, it is just as readable, and, IMHO, it is actually *more* readable. Anyway, on the the question... If I do this: NSMutableDictionary *theDicRow = [NSMutableDictionary dictionaryWithObjectsAndKeys: @Text A, @colA, @, @colB, nil ]; The result is: [2355:10b] ( { colA = Text A; } ) But I wanna have the empty string back. So it seems, that the empty string is converted to nill and the controller is killing them out. How can I change this reaction with empty strings? I need this @ Strings. I am not surprised to see this behavior, for various reasons. The short answer is no, you can't have an empty string for a key in conjunction with an NSArrayController. What would be the key path for an empty string? Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSArrayController: Objects with empty strings
MyApps wrote: But I wanna have the empty string back. So it seems, that the empty string is converted to nill and the controller is killing them out. This works fine for me. CODE: NSMutableDictionary* dict = [NSMutableDictionary dictionaryWithObjectsAndKeys: @Text A, @colA, @, @colB, nil ]; NSLog( @dict: %@, dict ); OUTPUT: 2009-04-28 12:31:39.881 foo[2471] dict: {colA = Text A; colB = ; } The controller could still be killing them out as you put it, but the problem is not because the empty string is nil. The dictionary is definitely being created with the key colB having a value of an empty string. -- 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: Repositioning the Field Editor
Continuing on with the mystery, I have tried the following code in my NSTableView subclass (below, not yet solved though). I have got it so that the rect returned by [fieldEditor frame] is not empty, but gives exactly the frame it should. Still though, modifying the frame to something different makes no difference. Is there a way to prompt the field editor to redraw itself in accordance with the new frame? In the documentation for -editColumn:row:withEvent:select:, I noticed that it sends -selectWithFrame:inView:editor:delegate:start:length: and -editWithFrame:inView:editor:delegate:event: to the field editor’s NSCell object with the NSTableView as the text delegate. So my call to super is doing that. Could it be that I need to intervene somehow in these NSCell methods? -(void)editColumn:(NSInteger)columnIndex row:(NSInteger)rowIndex withEvent:(NSEvent *)theEvent select:(BOOL)flag { [super editColumn:columnIndex row:rowIndex withEvent:theEvent select:flag]; NSTextView *fieldEditor = (NSTextView *)[[self window] fieldEditor:YES forObject:nil]; // Change the text colour to red, just to confirm I've got ahold of the actual field editor that is being used (I do) [fieldEditor setTextColor:[NSColor redColor]]; // Get the field editor frame (it is the correct frame) NSRect cellRect = [fieldEditor frame]; NSLog(@1. fieldEditor x origin: %f,cellRect.origin.x); // output: 127 // Change cellRect x origin, but don't extend the field width cellRect.origin.x += 20; cellRect.size.width -= 20; // Set fieldEditor frame to new cellRect [fieldEditor setFrame:cellRect]; [fieldEditor setNeedsDisplay:YES]; cellRect = [fieldEditor frame]; NSLog(@2. fieldEditor x origin: %f,cellRect.origin.x); // output: 147 } On 27-Apr-09, at 7:19 PM, K. Darcy Otto wrote: I have a field editor which I need to reposition in my tableView – specifically, I need to move it a few pixels to the right. The following post: http://www.cocoabuilder.com/archive/message/cocoa/2009/3/16/232513 makes two suggestions: (i) implement the move in -viewWillDraw in the field editor subclass, and (ii) reposition the field editor after calling super in -editColumn:row:withEvent:select: in the tableView subclass. Neither of these seem to make any difference to where the field editor is drawn. Here is my code with respect to (i), contained in the field editor subclass: -(void)viewWillDraw { NSRect frame = [self frame]; NSLog(@Old: %f,frame.origin.x); frame.origin.x += 50.0; [self setFrame:frame]; frame = [self frame]; NSLog(@New: %f,frame.origin.x); [super viewWillDraw]; } Now, I can confirm this method is being called, and by means of the NSLog statements, the frame is being changed prior to the call to super. Unfortunately, the field editor is drawn where is usually is drawn, with no shift in place. With respect to (ii), contained in the tableView subclass: -(void)editColumn:(NSInteger)columnIndex row:(NSInteger)rowIndex withEvent:(NSEvent *)theEvent select:(BOOL)flag { [super editColumn:columnIndex row:rowIndex withEvent:theEvent select:flag]; NSText *fieldEditor = [[self window] fieldEditor:YES forObject:self]; NSRect fieldEditorFrame = [fieldEditor frame]; fieldEditorFrame.origin.x += 50.0; [fieldEditor setFrame:fieldEditorFrame]; } Here, it turns out that even though fieldEditor points to the custom field editor object, fieldEditorFrame turns out to be empty. And again, the field editor is drawn where it is usually drawn, with no shift in place. Any help would be greatly appreciated. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: passing complex objects between threads
Thanks for the sugestion. I will keep the idea of passing object IDs in mind when that situation comes up. But I think I misled you. My data was not in Core Data yet, but rather in an archive I needed to unfreeze and place in Core Data. In the end, I did something similar to what you suggested—opening a new context in a new thread, parsing the file from within the thread, and importing and storing in Core Data. Meanwhile, I updated the original context (app's context) so that the interface would get updated as data came in. The approach (option A in my original question) worked fine. But as I said, this approach skirts the issue. How do you pass complex objects from one thread to another? OR, to put it another way, Why do deeper elements disappear? For example, I tried passing a reference like this: [openImportThread: self] (where self = appController) Since I cached the table to be imported as an ivar, that should allow me to access the table in appController. Unfortunately, the table's records all disappear and are no longer accessible from the new thread, even if I go something like: WITHIN THREAD NSArray *records = [[owner myTable] records]; // records are no longer there even though other single-level table info is (numRecs etc.) The same thing happens if I try to cache the table in a global variable. The minute I enter the thread, access to the actual records (found within an array instance variable) disappears. WITHIN THREAD NSArray *records = [globalTableRef records]; // records are no longer there // records are no longer there even though other single-level table info is (numRecs etc.) In the case of global variables, that could be a deep-shallow copy distinction, but in the case of accessing the appController's cached ivar, I don't see how copying is even involved. Why do the records disappear (from access) once you enter another thread? And how do you prevent the objects inside a collection-based ivar from disappearing when you enter a new thread? On Apr 25, 2009, at 1:53 AM, Chris Hanson wrote: Indeed. Furthermore, since you're working with Core Data, you may not actually want those 50K objects passed from one thread to another; Core Data strongly prefers threads to work in entirely separate managed object contexts. If you use one NSManagedObjectContext per thread, but these contexts use the same NSPersistentStoreCoordinator, Core Data has just the solution for you. I did something similar to this. If you do want to still pass information from the background thread to the main thread, all you need to pass are the managed object IDs of the (saved) objects the main thread will be interested in. You can just use -[NSObject performSelectorOnMainThread:withObject:waitUntilDone:] for this and pass either individual object IDs or collections of them. Then on the main thread, you can ask the main thread's managed object context for the managed object with that ID, and it'll hand you back an appropriate one that you can use for your user interface. Doesn't work because the data is not in Core Data yet. I will keep in mind for future, though. 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: NSArrayController: Objects with empty strings
On Apr 28, 2009, at 1:39 PM, Alexander Spohr wrote: Am 28.04.2009 um 21:22 schrieb Keary Suska: NSMutableDictionary *theDicRow = [NSMutableDictionary dictionaryWithObjectsAndKeys: @Text A, @colA, @, @colB, nil ]; I am not surprised to see this behavior, for various reasons. The short answer is no, you can't have an empty string for a key in conjunction with an NSArrayController. What would be the key path for an empty string? As a note: the code sets the value to the empty string. The key is colB. It pays to pay attention. Sorry for that. Anyway, I am still not entirely surprised, as the GUI doesn't distinguish between empty and nil values. At least as far as an NSTextField/Cell is concerned. I would be curious whether there is a binding to the value, and if unbound, the behavior remains. I have had to deal with this situation particularly as it related to RDBMS's, which *do* distinguish between NULL and and empty, and it's an important distinction. In cases where you know you will need to handle an empty value and you want to make sure it will *never* be nil, you can use a transformer. HTH, Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cocoa-dev Digest, Vol 6, Issue 641
I remember having this problem while developing Core Data apps for testing purposes. It often happened while I modified the app in various ways. I think the solution was to delete the store in ApplicationSupport/ app name. If you have legacy data, you'll have to export that from an old version and import to the new one, however. On Apr 27, 2009, at 12:46 AM, cocoa-dev-requ...@lists.apple.com wrote: Message: 2 Date: Sun, 26 Apr 2009 19:23:42 -0400 From: Walker Argendeli heckler0...@bellsouth.net Subject: Core Data Suddenly Losing Changes To: cocoa-dev@lists.apple.com Message-ID: 74cf5427-d3b7-4c71-b492-dd73366c2...@bellsouth.net Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes I've been working on a project that uses Core Data for a while now. I recently changed the model and ran it, but I noticed an odd behavior: I wan't informed that the model had changed and was incompatible. I went ahead and deleted the old xml file and when running the application again, it created another file. The only problem is that Core Data has stopped saving. EVery time I open the application, I'm presented with a blank slate. I haven't been religiously using subversion, but I had a commit several days, so I checked out that revision. It has the exact same problem, but I'm certain this wasn't happening a few days. I'm not sure what I could've done that could have caused this, but I'm completely stuck and going crazy trying to get my app to work again. Thanks, - Walker Argendeli ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
[OT] Re: Need guidance on data structure
On 28 Apr 2009, at 02:47, Graham Cox wrote: Because of the cyclic nature of the network though, there isn't a way I can see to simply sort the objects into the right order. I snipped most of the above; anyone who cares to read it should refer to the original message. I think the crux of the problem here is that a road can be both child and parent in the same relationship, or child and grandparent and so on. This happens because you're allowing arbitrary interconnection, and the child-parent relationship is important because of the colouring issue that you mention (i.e. the parent road's colour should dominate at junctions). So the question is what to do about all of this. I *think* the answer might be as follows: 1. Draw *all* the casements (I'm assuming they're the same colour here; if not, you might need to do step 2 first to break the casements up as well). 2. For each road, break it into segments such that each segment has no more than one junction with other roads. So e.g. (C) | (A)==+(B) | (E)+=(F) | (D) you would break road CD between the AB-CD junction and the EF-CD junction. You might have fun handling more complex junctions... 3. Now each road segment only has one junction, so you can sort the segments into the correct rendering order using a topographic sort routine, then simply draw their strokes in that order. 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: C string constant-NSString constant without defining twice?
I tried this and it absolutely works great - although I too had thought that it wouldn't. Who woulda thunkit? Erg From: Erik Buck erik.b...@sbcglobal.net To: cocoa-dev@lists.apple.com Sent: Tuesday, April 28, 2009 8:18:56 AM Subject: Re: C string constant-NSString constant without defining twice? I haven't tried, but I don't think the following works because of the way the pre-processor inserts spaces: #define kConstCString This is a const c string #define kConstNSString @kConstCString Don't hard code paths! Use NSHomeDirectory() or NSTemporaryDirectory() or NSSearchPathForDirectoriesInDomains(). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/erg_consultant%40yahoo.com This email sent to erg_consult...@yahoo.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Storing a table view in user defaults
On 2009 Apr 28, at 11:41, Ryan Briones wrote: Sorry for not using the proper terminology. I have a table view whose columns are bound to an array controller (Controller Key: arrangedObjects, Model Key Path: name, etc) and the array controller is bound You didn't say which binding. Should be the 'value' binding. to shared user defaults (Controller key: values, Model Key Path: arrayOfThings). Also I have a button that send add: to the array controller and a button that sends delete: and Enabled is bound to canRemove: on the array controller. Seems like pretty standard setup from what I can tell. Yes, it is. Sorry to be picking nits but what you've described is very similar to what I have done. The answer is going to be in a nit. Add an item to your table, then gracefully quit your application. Open the file ~/Library/Preferences/com.myCompany.MyApp.plist with a plist editor and look at arrayOfThings. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Why is NSString-FSRef so hard?
I was reading it wrong. Page 12 Strings Programming Guide For Cocoa: Important: NSString provides a number of methods to use Cstrings directly (such as stringWithCString:,initWithCString:, initWithCString:length:, and initWithCStringNoCopy:length:freeWhenDone:). These methods use the default C string encoding and may lose information in the conversion from that encoding. You are strongly discouraged from using these methods as are deprecated in Mac OS X v10.4. From: Clark Cox clarkc...@gmail.com To: Erg Consultant erg_consult...@yahoo.com Cc: cocoa-dev cocoa-dev@lists.apple.com Sent: Tuesday, April 28, 2009 9:07:00 AM Subject: Re: Why is NSString-FSRef so hard? On Mon, Apr 27, 2009 at 10:13 PM, Erg Consultant erg_consult...@yahoo.com wrote: Apple's doc's specifically say to stay away from using the CString routines which require encodings. Where do they say that? -- 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: C string constant-NSString constant without defining twice?
Except in the case where one line of code creates the temp file and then another immediately uses it and deletes is - as in my case. There is zero chance the user could FUS faster than my 2 lines of code create and delete the file. Erg From: Graham Lee graham@sophos.com To: Stephen J. Butler stephen.but...@gmail.com; Cocoa-Dev List cocoa-dev@lists.apple.com Sent: Tuesday, April 28, 2009 9:39:05 AM Subject: Re: C string constant-NSString constant without defining twice? On 28/04/2009 16:51, Stephen J. Butler stephen.but...@gmail.com wrote: On Tue, Apr 28, 2009 at 10:18 AM, Erik Buck erik.b...@sbcglobal.net wrote: Don't hard code paths! Use NSHomeDirectory() or NSTemporaryDirectory() or NSSearchPathForDirectoriesInDomains(). Not only that, but hardcoding filenames in tmp directories is generally considered a security bug. You should be using mktemp or one of its ilk. Not sure if there's a Cocoa API for that. It's not only a security bug but a buggy bug. If you see what I mean :-). What happens if two users are fast-user-switching on the same box? Both apps are using the same temporary data... Cheers, Graham. -- Graham Lee Senior Mac Software Engineer tel: +44 1235 540266 SOPHOS - simply secure Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/erg_consultant%40yahoo.com This email sent to erg_consult...@yahoo.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Storing a table view in user defaults
Check out the sample code here that demonstrates storing a dictionary in defaults with no code. http://idisk.mac.com/steven.riggs-Public?view=web I hope it helps... Steven Riggs On Apr 28, 2009, at 11:04 AM, Ryan Briones wrote: I'm a relative newb when it comes to cocoa programming, but I've been trying to finish of a project and put it out there so I can get some feedback and continue to get better. My problem is that I have a table view that's bound to an array controller backed by user defaults in IB. Adding a single new row works fine, but if I add any more, the data from the previous rows gets wiped out, but the actual rows get preserved. Further more, if I create a row and exit/relaunch the rows are persisted, but the data is not. If feel like I'm missing some important detail, but I can't figure out what. Any help is appreciated. Thanks. -- Ryan Carmelo Briones ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/steven.riggs%40me.com This email sent to steven.ri...@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: Why is NSString-FSRef so hard?
Well, I finally got it to work - but it took a lot of work. How does one launch an exe inside an app bundle if LSOpenApplication isn't desgined to do that? Erg From: Jean-Daniel Dupas devli...@shadowlab.org To: cocoa-dev cocoa-...@lists.apple..com Sent: Tuesday, April 28, 2009 9:59:07 AM Subject: Re: Why is NSString-FSRef so hard? Le 28 avr. 09 à 17:47, Michael Ash a écrit : On Tue, Apr 28, 2009 at 1:13 AM, Erg Consultant erg_consult...@yahoo.com wrote: Apple's doc's specifically say to stay away from using the CString routines which require encodings. So now the encoding issue goes away. The problem is LSOpenApplication() does not like the FSRef I pass it which gets created from the path NSString-CFURL-FSRef. They state the opposite. They say to stay away from the ones which do NOT require encodings. That's because the ones without encodings use the system encoding which is not guaranteed to be anything useful. The ones with encodings require you to specify them yourself and are therefore just fine. And to add a word about your LS issue, it's because to launch an app, you should create a ref on the bundle, not on the executable.. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/erg_consultant%40yahoo.com This email sent to erg_consult...@yahoo.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Why is NSString-FSRef so hard?
On Tue, Apr 28, 2009 at 5:03 PM, Erg Consultant erg_consult...@yahoo.com wrote: How does one launch an exe inside an app bundle if LSOpenApplication isn't desgined to do that? exe? You need to specify what you mean: executable binary, which is just a plain binary file, or application, which is wrapped in a .app bundle. If you just want to launch a binary as a child task, you can use NSTask and -[NSBundle pathForAuxiliaryExecutable:]. --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: Why is NSString-FSRef so hard?
This is a DRM situation where there are multiple app executables inside the main .app bundle. From: Kyle Sluder kyle.slu...@gmail.com To: Erg Consultant erg_consult...@yahoo.com Cc: cocoa-dev cocoa-dev@lists.apple.com Sent: Tuesday, April 28, 2009 2:11:40 PM Subject: Re: Why is NSString-FSRef so hard? On Tue, Apr 28, 2009 at 5:03 PM, Erg Consultant erg_consult...@yahoo.com wrote: How does one launch an exe inside an app bundle if LSOpenApplication isn't desgined to do that? exe? You need to specify what you mean: executable binary, which is just a plain binary file, or application, which is wrapped in a .app bundle. If you just want to launch a binary as a child task, you can use NSTask and -[NSBundle pathForAuxiliaryExecutable:]. --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: Need guidance on data structure
On Mon, Apr 27, 2009 at 9:47 PM, Graham Cox graham@bigpond.com wrote: A road can be connected to other roads. Currently each road keeps a list of the subroads that are connected to it, which is a parent-child relationship. A parent road can have any number of child roads, but a child road can only have a maximum of two parents - one for each end. (The parent could also be the same for each end, or it could have an unconnected end which is a nil parent for that end). Roads can connect to each other in any way you like, so in some cases a child road could be the parent of its own parent, and obviously there are many other kinds of cycles possible. The only thing currently not permitted is that a road can't loop back and connect to itself. This seems wrong. This situation is common in games, and the way it's dealt with is to instead use a directed acyclic graph: no more my son is my father relationships, instead using special node types with logic that understands the relationship of their children. You can also go the TeX route and iterate the system until you reach a fixed point or an oscillation. --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: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
On 2009 Apr 23, at 13:53, Melissa J. Turner wrote: Unwinding to the original message, the most correct thing to do would be to add a derived property letterGrade which is automatically updated whenever grade is, which then allows you to search against that. I don't know if a derived property is a managed property that appears in the .xcdatamodel, or a regular instance variable. If Melissa is referring to a managed property, if it is non-transient, then yes this could be used in the predicate of a Core Data fetch. The disadvantage is that now every object in every store has this redundant (derived) attribute. More important than the wasted bits is that custom setters are now required to keep the derived attribute in sync with its source attribute, opening a way to introduce bugs into future versions. If Melissa is referring to a regular instance variable, then it cannot be used in the predicate of a Core Data fetch and thus filtering must be done in RAM by -[NSArray filteredArrayWithPredicate], resulting in limited scalability. For my application, I chose the latter. Am I misunderstanding anything? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: How to make NSSplitView not dragable
On Tue, Apr 28, 2009 at 12:44 PM, Ashish Tiwari ashish_tiw...@persistent.co.in wrote: I have a horizontal NSSplitView, I want the splitter bar should remain in a fixed postion and user should not be able to change size of upper subview or lower subview by dragging it. What have you tried? Specifically, have you tried any of the NSSplitView delegate methods? Why do you want to draw a splitter if the user can't move it anyway? --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: C string constant-NSString constant without defining twice?
On Tue, Apr 28, 2009 at 4:58 PM, Erg Consultant erg_consult...@yahoo.com wrote: Except in the case where one line of code creates the temp file and then another immediately uses it and deletes is - as in my case. There is zero chance the user could FUS faster than my 2 lines of code create and delete the file. By virtue of you saying that, it will happen. Murphy's Law loves race conditions because it always wins. --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: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
On Tue, Apr 28, 2009 at 5:15 PM, Jerry Krinock je...@ieee.org wrote: If Melissa is referring to a managed property, if it is non-transient, then yes this could be used in the predicate of a Core Data fetch. The disadvantage is that now every object in every store has this redundant (derived) attribute. More important than the wasted bits is that custom setters are now required to keep the derived attribute in sync with its source attribute, opening a way to introduce bugs into future versions. We all love normalization. That is, until it hinders our progress. One of the things to keep in mind with Core Data is that you are *not* using an RDMBS. Sure, one might provide the backing storage under the hood, but the traditional concern with data normalization in an n-tier enterprise situation is with the data: the data must remain pure and accessible to any number of interfaces. Core Data is different: it's an object graph management framework for desktop apps. You are required by its very nature to couple the business logic much tighter to the data storage, since you really are storing business-logic-bearing model objects. So step 1 is to stop clinging to normalization rules. (My database professor would kill me for that sentence, but it's true.) There really is no redundancy here, because the data stored on disk is never really separated from the model objects which use that data. In an n-tier app, you would be correct to avoid storing the derived property. As for the logic required to maintain this relationship, that's why we have KVC/KVO! Implement +keyPathsForValuesAffectingValueForKey: as appropriate. Implement your KVC setters/getters for the independent attributes such that they invoke -setPrimitiveValue:forKey: for the required dependent properties. --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
CA -animator animation only works the first time
I have two standard Cocoa objects in my window that I animate using CA's AppKit -animator method. When my nib loads, I get the original NSRects of the two items by sending them the -frame message. I then recalc the rects to move the two views offscreen. When I show my window, I animate both views back into the window thusly: [ [ oudWindowIconView animator ] setFrame:destGameIconRect ]; [ [ oudWinowLogoImage animator ] setFrame:destLogoRect ]; This works fine - the first time. The next time I show my window and the same code runs, the two items are not visible in the window. The dest rects of the reanimated views are the same as the original view rects when the nib loads. So why does the animation work only the first time? Thanks, Erg ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
NSXMLParser and NSDocument
I've been having 2 intermittent compilation errors on 10.3.9 in - (BOOL)loadDataRepresentation:(NSData*)data ofType:(NSString*)fileType { BOOL success; NSString * lowercaseFileType = [fileType lowercaseString]; NSLog(@fileType=%S, lowercaseFileType); if ([lowercaseFileType isEqualToString:@abc]) { JGOAbcParser * abcParser = [[JGOAbcParser alloc] initFromAbcData:data]; if (abcParser) success = YES; } else if ([lowercaseFileType isEqualToString:@defg]) { NSXMLParser * xmlParser = [[NSXMLParser alloc] initWithData:data]; [xmlParser setDelegate:JGOXMLParser]; success = [xmlParser parse]; } [...] return success; } The first is a warning where I try to log the file type, grumping that the 2nd argument is not of the desired type. (Converting it to lower case was an attempt to see whether it would affect the warning, and at first I thought it did. But, in any case, it makes the later if condition simpler.) The second is error: parse error before JGOXMLParser and point to [xmlParser setDelegate:JGOXMLParser]; I understand that – loadDataRepresentation:ofType: method is valid in 10.3.9 but deprecated in 10.4 but I have to work with what I have. Does the delegate have to be an instance? If so, would I instantiate it right before setting the delegate? The manuals and examples are not enlightening, since most simply [fred setDelegate:self] Do I have to implement all delegate methods? I am under the impression it would check and revert to defaults on ones that I did not. Here are the declarations of the ones I have, now: - (void)parserDidStartDocument:(NSXMLParser*)parser; - (void)parser:(NSXMLParser*)parser didStartElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI qualifiedName:(NSString*)qName attributes:(NSDictionary*)attributeDict; - (void)parser:(NSXMLParser*)parser foundCharacters:(NSString*)string; - (void)parserDidEndDocument:(NSXMLParser*)parser; And, finally, what is that namespaceURI parameter? The descriptions are non-descriptive to me. Is that supposed to be a URI to a DTD or XML schema, or something completely different? Since it's not doing validation, I was hoping to dispense with a DTD or schema, for now, and just pick and choose what tags to process. manuals, etc., consulted: _Event-Driven XML Programming Guide for Cocoa_ _Application Architecture Overview_ _Document-Based Applications Overview_ _NSDocument Class Reference_ Aaron Hillegass 2002 _Cocoa Programming for Mac OS X_ http://www.w3schools.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: Why is NSString-FSRef so hard?
On Apr 28, 2009, at 4:13 PM, Erg Consultant wrote: This is a DRM situation where there are multiple app executables inside the main .app bundle. NSTask. Charles ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSRunLoop vs. NSThread sleep
Hello, When implementing the while-loop in the main function of an NSThread, is it correct to assume it is more efficient on the operating system to run the current run-loop until a specified date rather than just use NSThread sleepUntilDate to obtain the delay? I ask because I don't really need a formal run loop or special input source as I'm just checking a shared queue for data (and the delay is to allow the thread to gracefully exit). So it's simpler to code just the NSThread sleep, however, I am guessing that will cause me context switching performance issues and I'd be better off using the NSRunLoop? Finally, is it acceptable to use the NSThread's cancelled/isCancelled mechanism to check for the thread-exit hint, rather than set/check a global variable in the NSThread threadDictionary (as Apple's documentation shows)? Thank You, - 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: iphone SDK session duration
On Apr 28, 2009, at 5:10 PM, Bess Ho wrote: Sorry for the delay in response. I'll need more help. I follow suggestions on using applicationDidFinishLaunching: and applicationWillTerminate: methods on AppDelegate. It won't print NSLog when I stop the app on Console and throw errors when I leave the app on simulator by pressing the home button to exist the app like the device. I didn't get any warnings or errors on building the project. I used NSLog(@Session: %.1f, [now timeIntervalSinceDate:then]); Please help! project code: http://code.google.com/p/iphonebuilder/downloads/list - (void)applicationDidFinishLaunching:(UIApplication *)application { // Starting Session } - (void)applicationWillTerminate:(UIApplication *)application { // Ending Session } Errors on console when I exit the app on simulator *** -[NSObject timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x521fe0 2009-04-28 17:07:32.283 sessiontime[22584:20b] CoreAnimation: ignoring exception: *** -[NSObject timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x521fe0 Just looking at this I can tell you the problem is the now object is not an NSDate - it's an NSObject. You need to create a valid NSDate. Luke On Wed, Apr 22, 2009 at 9:57 AM, Luke the Hiesterman luket...@apple.com wrote: What's wrong with the NSDate solution below? Luke On Apr 21, 2009, at 10:49 PM, Bess Ho wrote: I couldn't get any working responses from iphone developer forum or iphone meetup group. I am hoping that this group with more experience cocoa developers with understanding on MVC model, Xcode. On Tue, Apr 21, 2009 at 6:47 PM, Luke the Hiesterman luket...@apple.com wrote: Sounds like you've already answered your question. Luke On Apr 21, 2009, at 4:00 PM, Bess Ho wrote: Is this appropriate mailing list to ask iphone SDK questions? How do you measure session duration on a utility application with 3 ViewControllers? Use NSDate to mark the starting and ending the session and print the time lapsed on NSLog. -- Bess Ho ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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 -- Bess Ho -- Bess Ho ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSDateFormatter for ISO8601
On Apr 28, 2009, at 1:57 PM, Jeffrey Oleander wrote: On Mon, 2009/04/27, Martijn van Exel mve...@gmail.com wrote: Unrelated: one of the XML attributes that needed parsing was a ISO8601 style date string, for which neither NSDate nor NSDateFormatter curiously does not seem to provide a parser. Maybe this would work. http://boredzo.org/iso8601parser/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: C string constant-NSString constant without defining twice?
On Apr 28, 2009, at 5:15 PM, Kyle Sluder wrote: Except in the case where one line of code creates the temp file and then another immediately uses it and deletes is - as in my case. There is zero chance the user could FUS faster than my 2 lines of code create and delete the file. By virtue of you saying that, it will happen. Murphy's Law loves race conditions because it always wins. Not to mention that an attacker putting your app under pressure will use nasty tricks to purposely trigger the race condition. Apple has a surprisingly comprehensive guide to filesystem (and other) security issues, whose advice they blatantly ignore, but you should follow: http://developer.apple.com/documentation/Security/Conceptual/SecureCodingGuide/Introduction.html One of my personal gripes: If you look at the implementation of, say, mkstemp() and tmpfile() down at the Libc level, you find that tmpfile() is implemented *in terms of* mkstemp(). Unfortunately for some, tmpfile() also wraps the FD from mkstemp() in a FILE, when I want a NSFileHandle. [NSFileHandle initWithFileDescriptor:fileno(tmpfile()) closeOnDealloc:NO]. Oops, now I have to keep track of the FILE* for as long as the NSFileHandle* exists. Ugh! My eventual solution was to roll my own method as a category on NSFileManager: - (NSFileHandle *)openSecureTemporaryFileAndReturnError:(NSError **)outError; This method does all the exclusive atomic opening and unlinking and returns a nice NSFileHandle or NSError instead of mucking around with errno. -- 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: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
(apologies for the delay; I've been on vacation for the last few days and just got back) On Apr 28, 2009, at 14:32, Kyle Sluder wrote: So step 1 is to stop clinging to normalization rules. (My database professor would kill me for that sentence, but it's true.) There really is no redundancy here, because the data stored on disk is never really separated from the model objects which use that data. In an n-tier app, you would be correct to avoid storing the derived property. Even in an n-tier application there are situations where it makes more sense to denormalize data than cling to theoretical purity. Once common case is to avoid joins, because they're *expensive*. Sometimes, the dba level pain of maintaining duplicate/derived data is much less than the user level pain of doing a join to display information in a frequently accessed view. There's no general rule for when this becomes true, because it's data set and use dependent, and it's not something you should do casually or without understanding what you're doing, why, and what tradeoffs are involved, but it is part of building a schema that's does what you need it to do efficiently. You can see an example of denormalized data in the Leopard version of iCal. The badges on the corner of events in the varying day/week/month views displays meta-information about the relationship that contains the note/contact/etc data. Having the badge provides useful information (there are other people invited, click here for meeting material), but it's expensive to do the join just to decide whether or not to display that badge for any given event, so iCal stores a separate bit of information saying this event has notes/contacts/ etc. According to pure relational design, this is a Very Bad Thing, because it duplicates information that exists in the join tables and introduces the possibility of error into the database. According to real-world performance, not doing the join sped displaying those views up by an order of magnitude (more in the case of large calendars). Taking normalization to it's fullest extent, you end up with things like databases where a Person is a set of joins to a Names table (don't get me started on natural vs assigned integer keys ;-), but no one outside academia does that because it's overkill and inefficient for anything except theoretical work. As for the logic required to maintain this relationship, that's why we have KVC/KVO! Implement +keyPathsForValuesAffectingValueForKey: as appropriate. Implement your KVC setters/getters for the independent attributes such that they invoke -setPrimitiveValue:forKey: for the required dependent properties. This is what I was getting at, yes. Create a separate modeled property 'letterGrade' and have the mutator for 'percentageGrade' automatically update it whenever percentageGrade is changed. Add observers as necessary. +Melissa ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 and NSDocument
On 29/04/2009, at 8:34 AM, Jeffrey Oleander wrote: I've been having 2 intermittent compilation errors on 10.3.9 in - (BOOL)loadDataRepresentation:(NSData*)data ofType: (NSString*)fileType { BOOL success; NSString * lowercaseFileType = [fileType lowercaseString]; NSLog(@fileType=%S, lowercaseFileType); %S specifies a null-terminated array of 16-bit unicode characters. What you're passing is an NSString object. So the specifier should be the object specifier, %...@. [xmlParser setDelegate:JGOXMLParser]; The second is error: parse error before JGOXMLParser and point to [xmlParser setDelegate:JGOXMLParser]; I understand that – loadDataRepresentation:ofType: method is valid in 10.3.9 but deprecated in 10.4 but I have to work with what I have. Does the delegate have to be an instance? It has to be an instance of *something*. JGOXMLParser I'm assuming is the name of your class. You can't have static objects in Objective-C as you can in C++, so this statement is illegal. If you want your class to implement the delegate methods, you could pass [JGOXMLParser class], since a class is an object. Or you could instantiate an actual JGOXMLParser. The latter sounds by far the less weird of the two options. --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 and NSDocument
On 29/04/2009, at 11:51 AM, Graham Cox wrote: You can't have static objects in Objective-C Correction - I meant to say *stack* objects... --G. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
File Reading Problems
Hi everyone. I have a small problem with readToEndOfFileInBackgroundAndNotify which is that I can't seem to get it to work right. ;) I am seeding the connection with the file name, and everything looks right except that I keep getting NSConcreteFileHandle: 0x1abfd0 and *** -[NSConcreteFileHandle length]: unrecognized selector sent to instance 0x1abfd0 when attempting to use it. My code is as follows. - (void)awakeFromNib { NSFileHandle *remoteConnection = [NSFileHandle fileHandleForReadingAtPath:@/Users/user/Desktop/file.plist]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(readAllTheData:) name:NSFileHandleReadToEndOfFileCompletionNotification object:remoteConnection]; [remoteConnection readToEndOfFileInBackgroundAndNotify]; } - (void)readAllTheData:(NSNotification *)note { NSString *errors = nil; NSData *contentsOfDockFile = [note object]; NSLog(@%@, contentsOfDockFile); NSDictionary *testing = [NSPropertyListSerialization propertyListFromData:contentsOfDockFile mutabilityOption:NSPropertyListImmutable format:nil errorDescription:errors]; NSLog(@%@, testing); [[NSNotificationCenter defaultCenter] removeObserver:self name:NSFileHandleReadToEndOfFileCompletionNotification object:[note object]]; [testing release]; } Thanks for any help. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: File Reading Problems
On Tue, Apr 28, 2009 at 9:19 PM, Pierce Freeman piercefreema...@comcast.net wrote: - (void)readAllTheData:(NSNotification *)note { NSString *errors = nil; NSData *contentsOfDockFile = [note object]; NSLog(@%@, contentsOfDockFile); NSDictionary *testing = [NSPropertyListSerialization propertyListFromData:contentsOfDockFile mutabilityOption:NSPropertyListImmutable format:nil errorDescription:errors]; NSLog(@%@, testing); [[NSNotificationCenter defaultCenter] removeObserver:self name:NSFileHandleReadToEndOfFileCompletionNotification object:[note object]]; [testing release]; } [note object] is your NSFileHandle. You want [[note userInfo] objectForKey:NSFileHandleNotificationDataItem]]. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: File Reading Problems
Thanks for your help. I don't get those strange errors anymore, however no if I try to save the NSDIctionary to a file (NSDictionary's writeToFile), my app seems to freeze up and in the Debugger it says: Program loaded. sharedlibrary apply-load-rules all Attaching to program: `/Users/user/Desktop/location', process 3361. (gdb) On 4/28/09 7:35 PM, Stephen J. Butler stephen.but...@gmail.com wrote: On Tue, Apr 28, 2009 at 9:19 PM, Pierce Freeman piercefreema...@comcast.net wrote: - (void)readAllTheData:(NSNotification *)note { NSString *errors = nil; NSData *contentsOfDockFile = [note object]; NSLog(@%@, contentsOfDockFile); NSDictionary *testing = [NSPropertyListSerialization propertyListFromData:contentsOfDockFile mutabilityOption:NSPropertyListImmutable format:nil errorDescription:errors]; NSLog(@%@, testing); [[NSNotificationCenter defaultCenter] removeObserver:self name:NSFileHandleReadToEndOfFileCompletionNotification object:[note object]]; [testing release]; } [note object] is your NSFileHandle. You want [[note userInfo] objectForKey:NSFileHandleNotificationDataItem]]. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: File Reading Problems
On Apr 28, 2009, at 7:50 PM, Pierce Freeman wrote: Thanks for your help. I don't get those strange errors anymore, however no if I try to save the NSDIctionary to a file (NSDictionary's writeToFile), You're releasing a variable that you don't own (testing). See the Cocoa memory ownership rules at http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html . Why are you using NSFileHandle asynchronous reading for a plist file, anyway? This is unusual, to say the least. -- adam On 4/28/09 7:35 PM, Stephen J. Butler stephen.but...@gmail.com wrote: On Tue, Apr 28, 2009 at 9:19 PM, Pierce Freeman piercefreema...@comcast.net wrote: - (void)readAllTheData:(NSNotification *)note { NSString *errors = nil; NSData *contentsOfDockFile = [note object]; NSLog(@%@, contentsOfDockFile); NSDictionary *testing = [NSPropertyListSerialization propertyListFromData:contentsOfDockFile mutabilityOption:NSPropertyListImmutable format:nil errorDescription:errors]; NSLog(@%@, testing); [[NSNotificationCenter defaultCenter] removeObserver:self name:NSFileHandleReadToEndOfFileCompletionNotification object:[note object]]; [testing release]; } [note object] is your NSFileHandle. You want [[note userInfo] objectForKey:NSFileHandleNotificationDataItem]]. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/amaxwell%40mac.com This email sent to amaxw...@mac.com smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: File Reading Problems
Hey Adam: Thanks for your reply. I added [testing retain] after the declaration of the variable, and I no longer get the wheel of death and my app freezing up. In response to your comment about why I am using NSFileHandle, it is because in the final version of this app I will need to scan several hundred plist files and I would like the app to stay responsive during this process. I am aware that I could just use threading for this, but this seemed a less hassle way to accomplish the same thing. On 4/28/09 8:03 PM, Adam R. Maxwell amaxw...@mac.com wrote: On Apr 28, 2009, at 7:50 PM, Pierce Freeman wrote: Thanks for your help. I don't get those strange errors anymore, however no if I try to save the NSDIctionary to a file (NSDictionary's writeToFile), You're releasing a variable that you don't own (testing). See the Cocoa memory ownership rules at http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/MemoryMgmt/MemoryMgm t.html . Why are you using NSFileHandle asynchronous reading for a plist file, anyway? This is unusual, to say the least. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Storing a table view in user defaults
You were right there. All you have to do to get it to work is check 'Handles content as compound value' on the array controller content array binding. All the best, Steven Riggs On Apr 28, 2009, at 10:02 PM, Ryan Briones wrote: Hey, thanks! I actually ran across your code last night when I was first doing this. I ran your code and it worked fine. I created a test project to copy your code, and mine failed. I tried looking at every checkbox and every key path, nothing worked. I've uploaded my the test project to github. I'd love it if you guys could take a look, and tell me what I'm doing wrong. I feel like it's an exact copy, but it doesn't work. Hopefully this can provide an insight into my stupidity. http://github.com/ryanbriones/tableview-userdefaults If you don't have git, you can download a zip or tarball from the downloads tab. Thanks! On Tue, Apr 28, 2009 at 5:00 PM, Steven Riggs steven.ri...@me.com wrote: Check out the sample code here that demonstrates storing a dictionary in defaults with no code. http://idisk.mac.com/steven.riggs-Public?view=web I hope it helps... Steven Riggs On Apr 28, 2009, at 11:04 AM, Ryan Briones wrote: I'm a relative newb when it comes to cocoa programming, but I've been trying to finish of a project and put it out there so I can get some feedback and continue to get better. My problem is that I have a table view that's bound to an array controller backed by user defaults in IB. Adding a single new row works fine, but if I add any more, the data from the previous rows gets wiped out, but the actual rows get preserved. Further more, if I create a row and exit/relaunch the rows are persisted, but the data is not. If feel like I'm missing some important detail, but I can't figure out what. Any help is appreciated. Thanks. -- Ryan Carmelo Briones ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/steven.riggs%40me.com This email sent to steven.ri...@me.com -- Ryan Carmelo Briones ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: errors building framework
That was it. Thanks. On Apr 28, 2009, at 1:07 AM, cocoa-dev-requ...@lists.apple.com wrote: I am trying to create a framework out of some files that I use in a few apps. I expected this to be easy, but instead got a kazillion warnings, all of which take the form: objc_class_name_NAME referenced from some method in some file.o [MANY METHODS AND FILES LISTED] or objc_msgSendmsg referenced from some method in some file.o or NSLog referenced from some method in some file.o Since the files originally came from projects that work (and do have Cocoa.h imported), I'm at a loss as to why this error would come up. If someone knows, or knows where I could read about this issue, I'd really appreciate it. Thanks. Link your framework against Cocoa as well as importing it. 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
Errors occur when using NSOutputStream to transfer big files
Hi, All I'm trying to use the NSOutputStream class to transfer some audio file through Bonjour service which is implemented on the iPhone simulator.I try the following code with some small text files. It works well. But there are always some error occurs() when I try to send the bigger ones -- some audio file. Any suggestions ? Thanks ! NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *sendFile = [documentsDirectory stringByAppendingPathComponent: @test1.caf]; NSData *myData = [[[NSData alloc] initWithContentsOfFile:sendFile] autorelease]; uint8_t *readBytes = (uint8_t *)[myData bytes]; NSUInteger byteIndex = 0; int myData_len = [myData length]; while (_outStream [_outStream hasSpaceAvailable]) { readBytes += byteIndex; unsigned int len = ((myData_len - byteIndex = 1024) ? 1024 : (myData_len-byteIndex)); uint8_t buf[len]; (void)memcpy(buf, readBytes, len); len = [_outStream write:(const uint8_t *)buf maxLength:len]; byteIndex += len; } Emma ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Errors occur when using NSOutputStream to transfer big files
On 28 Apr 09, at 21:11, yiling wu wrote: I'm trying to use the NSOutputStream class to transfer some audio file through Bonjour service which is implemented on the iPhone simulator.I try the following code with some small text files. It works well. But there are always some error occurs() when I try to send the bigger ones -- some audio file. Let me guess: All your test files were under 1kb. uint8_t *readBytes = (uint8_t *)[myData bytes]; NSUInteger byteIndex = 0; int myData_len = [myData length]; while (_outStream [_outStream hasSpaceAvailable]) { This loop condition makes no sense. readBytes += byteIndex; This should probably be readBytes = byteIndex. Or eliminate the extra variable entirely. unsigned int len = ((myData_len - byteIndex = 1024) ? 1024 : (myData_len-byteIndex)); uint8_t buf[len]; (void)memcpy(buf, readBytes, len); Come to think of it, why are you doing a memcpy at all? All of your data is already in a buffer; there's no need to put it into another buffer just to write it. len = [_outStream write:(const uint8_t *)buf maxLength:len]; byteIndex += len; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
How to get finder type Open With dialog box
Hello ppl Cocoa gives me default file associations with apps in this code NSString * path_ok= @/Users/pd/Desktop/pd.rtf; [ws openFile:path_ok withApplication:nil]; But when i try this i get an obvious error NSString * path= @/Users/pd/Desktop/pd2.large; NSWorkspace * ws = [NSWorkspace sharedWorkspace]; [ws openFile:path withApplication:nil]; i am using the file with .large custom extension What i want to do is, when my code encounters a unknown file extension, it should open the finder type Open With dialog box for user to choose the app from the list. How to do this in cocoa, NSOpenPanel doc is not helping or i am looking in the wrong direction?? Please help Advance Thanks -Parimal -- -- Warm Regards, Parimal Das ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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