Re: NSString camel case
On Apr 11, 2009, at 11:35 PM, Devraj Mukherjee wrote: My app receives strings from a web service that look like everything_else (no quotes) I would like to convert these strings to Everything Else. My initial attempts were going to be using a loop through the string inspecting it for occurances but I think that will make the application slow as there are a lot of these strings. Can I use regular expressions or certainly a better way? Any ideas? NSString *result = [[originalString stringByReplacingOccurrencesOfString:@_ withString: @ ] capitalizedString]; This is about the fastest straightforward means of doing what you described, assuming that your strings are as simple as you describe in all cases. There are faster ways, but they aren't nearly so simple. Thinking something is going to be slow is very different from something actually being slow enough to impact your application's user's experience. b.bum ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSString camel case
Cocoa has always been lacking in the RegEx department (at least the 'built-in' Cocoa classes, there's a bunch of third-party regex frameworks), especially when compared to languages like Python. Since your situation isn't very complex, I would just use the bread-n-butter string APIs: NSString *originalString = @everything_else_is_my_name; NSArray *originalStringComponents, *resultingComponents; NSMutableString *result = [NSMutableString string]; originalStringComponents = [originalString componentsSeparatedByString: @_]; for (NSString *currentStringComponent in originalStringComponents) [result appendString: [NSString stringWithFormat: @%...@%@, [currentStringComponent capitalizedString], (currentStringComponent != [originalStringComponents lastObject] ? @ : @)]]; NSLog(@%@, result); (Better-formatted version here: http://pastie.org/444173). Note that this snippet isn't incredibly efficient, but should get the point across... David ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [SOLVED] Rendering OpenGL in timed loop (CoreVideo).
That did it, adding [[ self openGLContext ] flushBuffer ]; To the end of getFrameForTime: did the trick. Thanks. On 12/04/2009, at 03:13 , Michael Ash wrote: On Sat, Apr 11, 2009 at 2:20 AM, Brian Bruinewoud br...@darknova.com wrote: Ok. That works. I was coming from an NSOpenGLView example where the view sets the context before the drawRect is sent. Any it, doesn't crash/hang/stop now, but it doesn't draw anything, either... :( Does identical code placed in drawRect: (without the context setting stuff, of course) draw? If so, it's probably a flushing problem. Be sure to flush your GL context before you exit. I thought of another possible approach. Since NSOpenGLView tries to act like a regular NSView, it may be sufficient to wrap your calls in a lockFocus/unlockFocus pair. 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/brian%40darknova.com This email sent to br...@darknova.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: NSPredicateEditorTemplateRow , pop up with Core Data objects
Hello, On Apr 10, 2009, at 23:37 , Dan Waltin wrote: I'm trying to create a NSPredicateEditorTemplateRow where the last view is a popup, containing every item of a particular CoreData entity (named StudyVisit). I'm doing something similar (and it's working fine for me). Then I override the templateViews method, as follows: - (NSArray *)templateViews { NSArray *parentViews = [super templateViews]; NSMenu *menu = [[parentViews objectAtIndex:2] menu]; if (studyVisitsController != nil) { for (id studyVisit in [studyVisitsController arrangedObjects]) { [menu addItemWithTitle:[studyVisit valueForKey:@title] action:nil keyEquivalent:@]; } } return parentViews; } One possible pitfall I can think of is that studyVisitsController is indeed nil (e.g. directly after unarchiving). To force the predicateEditor to recreate its internal views / structures, I save its rowTemplates, set them to nil, and set them back to the original array once all the connections are valid (i.e. windowDidLoad for me). If you want to use more of the superclass-functionality, also make sure to set the representedObject of the menu-items to the value you want represented (e.g. [NSExpression expressionForConstantValue:value]. Last but not least, did you implement copyWithZone: so that copies of the template also have the controller? HTH, Daniel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Core Data done loading
I have a document-based Core Data application, and I want to do some initializing when the application is done loading data from the persistent store. I couldn't find any notifications in NSManagedContext for this. Ivan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 done loading
On Apr 12, 2009, at 8:23 AM, Ivan C Myrvold wrote: I have a document-based Core Data application, and I want to do some initializing when the application is done loading data from the persistent store. The document doesn't load anything from the persistent store unless you tell it to fetch something... If you're using Cocoa bindings and an array controller to fetch data, see http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdBindings.html#//apple_ref/doc/uid/TP40004194-SW3 . mmalc ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSPredicateEditorTemplateRow , pop up with Core Data objects
On Apr 10, 2009, at 2:37 PM, Dan Waltin wrote: But here the studyVisitsController always contains 0 (zero) objects, although there ought to be a handful objects. Which means that I'm never adding any items to the menu. When is the templateViews method invoked? If your array controller is being populated automatically, see http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdBindings.html#//apple_ref/doc/uid/TP40004194-SW3 mmalc ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
stopping an application
What's the right way to have another process stop an application? Sending a SIGTERM doesn't seem to invoke the application shutdown dance; and signal handlers don't seem to establish themselves. Bill ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: @selector not working with (id)anObject
Basically I just need to use a function pointer. How does Cocoa do this? Put a function pointer member in your class and set it before you call detachNewThreadSelector on it... -- Scott Ribe scott_r...@killerbytes.com http://www.killerbytes.com/ (303) 722-0567 voice ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Build Settings for Release: App/Library is bloated
My .app file and library file have both quickly grown to be 13MB in disk size and I'm having a hard time figuring out why. I've been reading about build settings and anything else I can get my hands on but I can't seem to make significant improvements. I don't know a ton about what happens in the compiling process so I'm looking for some guidance in hopes I can get this smaller. I have pulled out some code and put it into a static library and I'll use that as my example. It is 26 classes each containing the dictionary words for one alphabet letter. They are just large arrays containing words, and that's it. No dependencies, no linked libraries. The library has only the .m files, and no header files. The disk size of all those files combined is 3.2MB. When I compile the library it becomes 13MB+. *Here are some of my build settings:* - Compile for Thumb: unchecked - Deployment Postprocessing: checked - Strip Debug Symbols During Copy: checked - Strip Style: Non-Global Symbols - Use Separate Strip: checked - Dead Code Stripping: checked - Don't Dead-Strip Inits and Terms: checked - Generate Debug Symbols: unchecked I'm having similar issues in the application itself, but I'm currently working on the static library so those are the numbers I have handy. Does that add up? Is there something else I'm missing? 12MB seems pretty ridiculous for this. Thanks in advance for any advice. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: stopping an application
On Apr 12, 2009, at 11:21 AM, Bill Janssen wrote: What's the right way to have another process stop an application? Send it the quit Apple event. 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: Build Settings for Release: App/Library is bloated
On Apr 12, 2009, at 3:11 PM, Miles wrote: My .app file and library file have both quickly grown to be 13MB in disk size and I'm having a hard time figuring out why. The .app bundle usually contains more than just your code. Have you examined it to see where the size is? Is it the executable, or some other file(s) included as resources? -- I.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: Build Settings for Release: App/Library is bloated
Yes, the size is in the executable which is about 8MB. It doesn't feel like this app should be that big considering the size of the files, but again I don't really know what all goes into making an app grow like this during compile. Any thoughts? On Sun, Apr 12, 2009 at 12:42 PM, I. Savant idiotsavant2...@gmail.comwrote: On Apr 12, 2009, at 3:11 PM, Miles wrote: My .app file and library file have both quickly grown to be 13MB in disk size and I'm having a hard time figuring out why. The .app bundle usually contains more than just your code. Have you examined it to see where the size is? Is it the executable, or some other file(s) included as resources? -- I.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: Build Settings for Release: App/Library is bloated
You might be compiling for four architectures - PPC 32/64, Intel 32/64. Compiling for each of these can of course greatly increase your app's size, since you're essentially combining four versions of your app into one binary file. Check your release target to see what architectures it's compiling for. Depending on how important a small app size is to you, you may want to compile just for one architecture. David ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Build Settings for Release: App/Library is bloated
Thanks for the response. Under my release configuration where I'm currently building it just shows 'Standard (iPhone OS: armv6)' under 'Architectures', and 'Build Active Architecture Only' is checked. On Sun, Apr 12, 2009 at 1:08 PM, Dave Keck davek...@gmail.com wrote: You might be compiling for four architectures - PPC 32/64, Intel 32/64. Compiling for each of these can of course greatly increase your app's size, since you're essentially combining four versions of your app into one binary file. Check your release target to see what architectures it's compiling for. Depending on how important a small app size is to you, you may want to compile just for one architecture. David ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Build Settings for Release: App/Library is bloated
On Sun, Apr 12, 2009 at 12:11 PM, Miles vardpeng...@gmail.com wrote: I'm having similar issues in the application itself, but I'm currently working on the static library so those are the numbers I have handy. Does that add up? Is there something else I'm missing? 12MB seems pretty ridiculous for this. In addition to what others are saying about checking to make sure you're only compiling for relevant architectures, you may also want to consider the significant compression opportunities you're missing. Why not just store the dictionary as a file in your bundle's resources? You can then perform the same shared prefix matching that is done in /usr/dict. --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: Build Settings for Release: App/Library is bloated
Thanks a lot, guys. I wasn't aware of this option, but I am going to look into it right now. In the meantime if you have a good link handy about how to do this I would appreciate it. Thanks again, and if there are any other suggestions I'm welcoming those as well. On Sun, Apr 12, 2009 at 1:14 PM, Kyle Sluder kyle.slu...@gmail.com wrote: On Sun, Apr 12, 2009 at 12:11 PM, Miles vardpeng...@gmail.com wrote: I'm having similar issues in the application itself, but I'm currently working on the static library so those are the numbers I have handy. Does that add up? Is there something else I'm missing? 12MB seems pretty ridiculous for this. In addition to what others are saying about checking to make sure you're only compiling for relevant architectures, you may also want to consider the significant compression opportunities you're missing. Why not just store the dictionary as a file in your bundle's resources? You can then perform the same shared prefix matching that is done in /usr/dict. --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
Obvious NSSegmentedControl Bug?
I need a sanity check before I file a bug report. sc is a 3-segment NSSegmentedControl with either Select One or Select Any as its mode. Segment 1 (the middle one) is selected in IB. Triggered as an action: NSLog(@Before:); NSLog(@ %d, [sc selectedSegment]); NSLog(@ %@, [sc isSelectedForSegment:0] ? @YES : @NO); NSLog(@ %@, [sc isSelectedForSegment:1] ? @YES : @NO); NSLog(@ %@, [sc isSelectedForSegment:2] ? @YES : @NO); [sc setSelected:NO forSegment:[sc selectedSegment]]; NSLog(@After:); NSLog(@ %d, [sc selectedSegment]); NSLog(@ %@, [sc isSelectedForSegment:0] ? @YES : @NO); NSLog(@ %@, [sc isSelectedForSegment:1] ? @YES : @NO); NSLog(@ %@, [sc isSelectedForSegment:2] ? @YES : @NO); Before: 1 NO YES NO After: 1 NO NO NO selectedSegment: [Returns t]he index of the currently selected segment, or -1 if no segment is selected. No segment is selected so selectedSegment should clearly be -1, right? 10.5.6 -- Seth Willits -- Seth Willits ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Build Settings for Release: App/Library is bloated
On Sun, Apr 12, 2009 at 1:19 PM, Miles vardpeng...@gmail.com wrote: In the meantime if you have a good link handy about how to do this I would appreciate it. If you put something in the Resources directory of the app bundle, you can use NSBundle's -pathForResource:ofType: and related methods to get their paths. Since you're working on iPhone, you need to be conscious of the tradeoffs of compressing resources on-disk (and taking the processor time to decompress them, either at startup or on load) versus leaving them uncompressed (and consequently consuming more disk space). Making them static arrays, however, is probably not a good idea. --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: Build Settings for Release: App/Library is bloated
OK, it's gradually making sense, but i still have some questions. I started trying to do something like this a while back -- storing it all in one file, then loading it, but I think after that is where I went wrong. I created an array out of the contents and used it searched it way. I then decided to split it into separate files to make the searching faster. I am now trying to do what you are recommending, and I have the file loaded with: NSString *filePath = [[NSBundle mainBundle] pathForResource:@dictionary ofType:@txt]; NSData *myData = [NSData dataWithContentsOfFile:filePath]; My questions are now about how to store the contents, because I don't think a nsdata or converting it to an array is what I want. Googling with keywords I've gathered from your emails have given me hints about using mmap, but I've finding very little info on it or how to use it. Is that what I should be trying to figure out? Searching shared prefix matching and similar keywords aren't turning up much either, so i'm a little stuck. I'd appreciate another boost or two if you wouldn't mind. As usual, thanks a lot! On Sun, Apr 12, 2009 at 1:30 PM, Kyle Sluder kyle.slu...@gmail.com wrote: On Sun, Apr 12, 2009 at 1:19 PM, Miles vardpeng...@gmail.com wrote: In the meantime if you have a good link handy about how to do this I would appreciate it. If you put something in the Resources directory of the app bundle, you can use NSBundle's -pathForResource:ofType: and related methods to get their paths. Since you're working on iPhone, you need to be conscious of the tradeoffs of compressing resources on-disk (and taking the processor time to decompress them, either at startup or on load) versus leaving them uncompressed (and consequently consuming more disk space). Making them static arrays, however, is probably not a good idea. --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: Build Settings for Release: App/Library is bloated
And BTW, my app is back down to 3.4MB after removing those classes and adding the dictionary in as a text file! That issue is now solved -- now I just need to figure out how to go about this approach :) awesome, thanks. On Sun, Apr 12, 2009 at 2:19 PM, Miles vardpeng...@gmail.com wrote: OK, it's gradually making sense, but i still have some questions. I started trying to do something like this a while back -- storing it all in one file, then loading it, but I think after that is where I went wrong. I created an array out of the contents and used it searched it way. I then decided to split it into separate files to make the searching faster. I am now trying to do what you are recommending, and I have the file loaded with: NSString *filePath = [[NSBundle mainBundle] pathForResource:@dictionary ofType:@txt]; NSData *myData = [NSData dataWithContentsOfFile:filePath]; My questions are now about how to store the contents, because I don't think a nsdata or converting it to an array is what I want. Googling with keywords I've gathered from your emails have given me hints about using mmap, but I've finding very little info on it or how to use it. Is that what I should be trying to figure out? Searching shared prefix matching and similar keywords aren't turning up much either, so i'm a little stuck. I'd appreciate another boost or two if you wouldn't mind. As usual, thanks a lot! On Sun, Apr 12, 2009 at 1:30 PM, Kyle Sluder kyle.slu...@gmail.comwrote: On Sun, Apr 12, 2009 at 1:19 PM, Miles vardpeng...@gmail.com wrote: In the meantime if you have a good link handy about how to do this I would appreciate it. If you put something in the Resources directory of the app bundle, you can use NSBundle's -pathForResource:ofType: and related methods to get their paths. Since you're working on iPhone, you need to be conscious of the tradeoffs of compressing resources on-disk (and taking the processor time to decompress them, either at startup or on load) versus leaving them uncompressed (and consequently consuming more disk space). Making them static arrays, however, is probably not a good idea. --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: Build Settings for Release: App/Library is bloated
I you're trying to search for shared prefixes, you might want to store your data in a data structure better suited for such tasks, such as a Trie http://en.wikipedia.org/wiki/Trie. Tries are fast and compact. Implementing a Trie isn't very difficult and, since it's such a commonly used data structure for string-related tasks, you'll be able to find good implementations on the web. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Build Settings for Release: App/Library is bloated
Thanks Wagner. I'm actually just needing to verify if a word is in the dictionary, but maybe this is still a good choice? If I don't need to search for shared prefixes would I be better off using sqlite so i don't have to load it all into memory? On Sun, Apr 12, 2009 at 2:34 PM, WT jrca...@gmail.com wrote: I you're trying to search for shared prefixes, you might want to store your data in a data structure better suited for such tasks, such as a Trie http://en.wikipedia.org/wiki/Trie. Tries are fast and compact. Implementing a Trie isn't very difficult and, since it's such a commonly used data structure for string-related tasks, you'll be able to find good implementations on the web. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Converting String Representations at Runtime
Is there an easy way to take input (user or file based) at runtime and convert unicode strings such as \u8D64 (UTF8 character) or a whole series of these to the human-readable characters they represent? I imagine I should be using NSScanner, but is there not some simple function or method to lookup and return the character as it should be represented? Happy to RTFM, just need a pointer to the docs I should be looking at. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSLog with %f and comparisons using ==
Chiming in late-ish... On Apr 11, 2009, at 12:26 PM, James Maxwell wrote: oooh, damn... I was afraid someone was going to say that. I just hoped there might be some way to force a float to conform to what NSLog %f prints... That seems like it might be a useful function - something like pround(aFloat), for print-round, to force any float number to round as the printf %f would round it. Anyway, that's obviously not available. It's not available because it's not possible. The print-formatting functions are rounding in decimal but floats are represented in binary. There are many values that seem simple to express in decimal but which are impossible to represent precisely in finite-precision binary. 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: Build Settings for Release: App/Library is bloated
You're welcome. It seems to me that storing your dictionary in a trie is a good idea anyway. Tries are compact and very fast for many kinds of string matching queries. Incidentally, here's an excellent implementation of tries, by the great OMNI folks: OFTrie - Implementation of the popular trie data structure http://www.omnigroup.com/developer/ If you can't, or would rather not, store the entire dictionary in memory, you can always split it into, for instance, 26 separate files, each containing all the words that start with a given letter. Then, once you have your query word, you can load into memory only the dictionary corresponding to the word's first letter, build a trie from that one dictionary, and do the search in logarithmic time (or not build a trie, but load that dictionary into an array, and do the search in linear time). Of course, building the trie takes time too, but if you're doing repeated queries within the same sub-dictionary, you only have to build the trie for that sub-dictionary once. Actually, you might want to do something a little more refined than that since the number of English words that start with, say, A, is much different than the number of words that start with, say, V. If you want your sub-dictionaries to have a relatively uniform size, you could split your full dictionary into more (or less) than 26 sub- dictionaries, depending on your specific needs. I would suggest that you write you application in a way that's independent of the specifics of how you're going to store the dictionary and do the searches. Then you're free to try different implementations and see which one is best for your needs. Wagner On Apr 12, 2009, at 11:55 PM, Miles wrote: Thanks Wagner. I'm actually just needing to verify if a word is in the dictionary, but maybe this is still a good choice? If I don't need to search for shared prefixes would I be better off using sqlite so i don't have to load it all into memory? On Sun, Apr 12, 2009 at 2:34 PM, WT jrca...@gmail.com wrote: I you're trying to search for shared prefixes, you might want to store your data in a data structure better suited for such tasks, such as a Trie http://en.wikipedia.org/wiki/Trie. Tries are fast and compact. Implementing a Trie isn't very difficult and, since it's such a commonly used data structure for string-related tasks, you'll be able to find good implementations on the web. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
How to create an ISO disc image
How can I create an ISO disc image. Can the disc recording framework do it? What about the DiskImages framework? I can't find an API for it. Thanks Sent from my iPhone ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: stopping an application
Nick Zitzmann n...@chronosnet.com wrote: On Apr 12, 2009, at 11:21 AM, Bill Janssen wrote: What's the right way to have another process stop an application? Send it the quit Apple event. Nick Zitzmann http://www.chronosnet.com/ I was afraid of that... Is there an easy way to do that from the command line given its PID? Bill ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Converting String Representations at Runtime
On Sun, Apr 12, 2009 at 6:01 PM, John Joyce dangerwillrobinsondan...@gmail.com wrote: Is there an easy way to take input (user or file based) at runtime and convert unicode strings such as \u8D64 (UTF8 character) or a whole series of these to the human-readable characters they represent? I imagine I should be using NSScanner, but is there not some simple function or method to lookup and return the character as it should be represented? Happy to RTFM, just need a pointer to the docs I should be looking at. Note that those are just unicode code points, not UTF-8 characters, whatever that would be. There is nothing built-in that I know of to convert these. You can search the string using one of the built-in methods, and then read the number with NSScanner's -scanHexInt:. If you know that your code points will always be no more than 4 digits (16 bits), which I think would have to be the case because otherwise you wouldn't know where to stop scanning the number, then you can make a string out of it easily using the %C format specifier, like so: unsigned value; if([scanner scanHexInt:value]) { NSString *str = [NSString stringWithFormat:@%C, value]; ... put str back into the original string ... } else // couldn't parse the value 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
MJPEG streams, webkit, and NSImage
Hi all, I recently got a wireless security camera, and although I can view it in Safari just fine, I was hoping to be able to integrate the feed into some existing code I have. I've seen a couple of posts on this list about webkit, and how difficult it was (is?) to use webkit to work with MJPEG streams, but no follow-up posts about how that might have been resolved by the OP. Are there any solid examples on working with MJPEG and webkit or, say, NSImage? I'd like to grab the MJPEG stream as a series of images, if possible, and assemble into a movie or discard them later. QT doesn't seem to have any support for MJPEG, but I've asked on the QT lists just to be safe. Any thoughts or suggestions would be greatly appreciated. Thanks! B ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Converting String Representations at Runtime
On Apr 12, 2009, at 9:21 PM, Michael Ash wrote: On Sun, Apr 12, 2009 at 6:01 PM, John Joyce dangerwillrobinsondan...@gmail.com wrote: Is there an easy way to take input (user or file based) at runtime and convert unicode strings such as \u8D64 (UTF8 character) or a whole series of these to the human-readable characters they represent? I imagine I should be using NSScanner, but is there not some simple function or method to lookup and return the character as it should be represented? Happy to RTFM, just need a pointer to the docs I should be looking at. Note that those are just unicode code points, not UTF-8 characters, whatever that would be. There is nothing built-in that I know of to convert these. You can search the string using one of the built-in methods, and then read the number with NSScanner's -scanHexInt:. If you know that your code points will always be no more than 4 digits (16 bits), which I think would have to be the case because otherwise you wouldn't know where to stop scanning the number, then you can make a string out of it easily using the %C format specifier, like so: unsigned value; if([scanner scanHexInt:value]) { NSString *str = [NSString stringWithFormat:@%C, value]; ... put str back into the original string ... } else // couldn't parse the value The above is failing to take into account the assumed knowledge that the code points won't be more than 4 characters long. What if you follow a \u sequence with characters (not intended to be part of the \u sequence) in the [0-9a-fA-F] set? For example, bar \u0020foo. -scanHexInt: will take that to mean 0x20f. You'd need to -scanCharactersFromSet:intoString: to read a sequence of hexadecimal digits, then check the length and back up using -setScanLocation: if it was more than 4 digits. Also, you'd truncate the resulting string at 4 digits and scan _that_ using -scanHexInt:. 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: Converting String Representations at Runtime
On Sun, Apr 12, 2009 at 10:51 PM, Ken Thomases k...@codeweavers.com wrote: The above is failing to take into account the assumed knowledge that the code points won't be more than 4 characters long. What if you follow a \u sequence with characters (not intended to be part of the \u sequence) in the [0-9a-fA-F] set? For example, bar\u0020foo. -scanHexInt: will take that to mean 0x20f. You'd need to -scanCharactersFromSet:intoString: to read a sequence of hexadecimal digits, then check the length and back up using -setScanLocation: if it was more than 4 digits. Also, you'd truncate the resulting string at 4 digits and scan _that_ using -scanHexInt:. It's not so much failing to account as it is assuming you'll set up the scanner appropriately. Obviously you would not set the scanner to run on the original source string, that simply wouldn't work, as you discuss. 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
[ANN] FeedParser released - an open source Cocoa RSS parser
FeedParser, a brand new NSXMLParser-based RSS parser for Cocoa, has been released as an open source project on GitHub[1]. The goal of this project is to provide an extensible RSS/Atom parser that works on both the iPhone and the desktop. To that end, it is based on NSXMLParser instead of NSXMLDocument. I recognize that PubSub is available for the desktop, but FeedParser was designed primarily with the iPhone in mind. In its current incarnation, FeedParser understands all of RSS 2.0 (although it does not expose all of the possible fields). It has also been verified to correctly parse sample RSs 0.91 and RSS 0.92 feeds. It has minimal support for Atom (to the extent that it understands atom:link elements embedded in RSS feeds), but the architecture is such that Atom support can be added over time. It also has support for RSS extensions such as DublinCore (though again, at the moment it only understands the dc:creator element but more support can be added easily). Any elements it does not recognize are recorded as extension elements, similar to the mechanism that PubSub uses, although FeedParser must use its own stripped-down replacement for NSXMLElement as it does not exist on the iPhone. At this point in time, FeedParser is perfectly usable for parsing RSS feeds in iPhone applications. It has also been tested on Mac OS X 10.5, but not on earlier versions. I expect it to work on 10.4 as well, but no earlier (it requires namespace support in NSXMLParser). FeedParser is covered under the MIT license. Feedback and patches are welcome. If you wish to provide patches, I encourage you to fork the project on GitHub and then send pull requests when you have useful changes. Please note that FeedParser is just a temporary name. FeedParser is also the name of a well-known Python RSS parsing library. If anybody has any good ideas for a name that's not taken, I would love to hear them. I would prefer to end up with something better than cocoa-feedparser. [1]: http://github.com/kballard/feedparser -Kevin Ballard -- Kevin Ballard http://kevin.sb.org kball...@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
How to open two nibs at app launch ? Beginners question
My regards to all on the list My name is Mario and I am now to Cocoa and Objective-C so I have some questions which will sound trivial to those with more experience. Please don't refer me to documentations because I have read them and looked for an answer and I tried to do it according to documentations but I still can't make it. That is why I posting here. The problem is: I have MainMenu.xib with only main menu whose File's Owner is NSApplication. I want to have MainWindow.xib with only a window but that will be launched also when the application starts. Now you will ask why separate nibs ? Never mind why ! I just want it that way ! Is that wrong ? So I read the docs and it says that I need to have File's Owner for that nib that is external to that nib. I tried putting NSWindowController but I don't know where and how do I instantiate that class ? I tried creating a subclass of NSWindowController and using it for the File's Owner and according to output of NSLog everything gets allocated and initialized but window does not get showed. I starting to think that I should do something in main.m but I don't think that would be the right way. I am doing something wrong so please point me the right way. Thanks to all in advance Mario ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 open two nibs at app launch ? Beginners question
On Apr 12, 2009, at 07:49, Mario Kušnjer wrote: The problem is: I have MainMenu.xib with only main menu whose File's Owner is NSApplication. I want to have MainWindow.xib with only a window but that will be launched also when the application starts. Now you will ask why separate nibs ? Never mind why ! I just want it that way ! Is that wrong ? It's not wrong at all. Separate nibs are the recommended way of doing this. So I read the docs and it says that I need to have File's Owner for that nib that is external to that nib. I tried putting NSWindowController but I don't know where and how do I instantiate that class ? I tried creating a subclass of NSWindowController and using it for the File's Owner and according to output of NSLog everything gets allocated and initialized but window does not get showed. I starting to think that I should do something in main.m but I don't think that would be the right way. I am doing something wrong so please point me the right way. You may just need to tell your window controller to display its window. Trying adding: [myWindowController showWindow: nil]; after you've initialized your window controller. Incidentally, in a non-document-based application (as your appears to be), a good place to put code to create your window controller would be in your application delegate's applicationDidFinishLaunching: method. You say you created a window controller. Where *did* you put that code? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: stopping an application
On Apr 12, 2009, at 8:55 PM, Greg Guerin wrote: Bill Janssen wrote: I was afraid of that... Is there an easy way to do that from the command line given its PID? Use the osascript command. Form a query using a 'whose' clause to select the process ID. I forget what the exact wording is, or whether to ask Finder or System Events, so you'll have to experiment. To start, open the scripting dictionary of System Events and under its Processes Suite, choose the 'process' class and find its 'unix id' property. That's the thing you need to use in a 'whose' clause. Then tell that application to quit. This works to quit an app with PID 902: tell app System Events to set x to file of first process whose unix id is 902 tell app (POSIX path of x) to quit I'm no AppleScript expert, so there's probably a briefer or more elegant way to do it. Hmm, now what did this have to do with Cocoa? 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