Re: Drawing a path and making an object follow that path IPHONE
You could probably start by studying the documentation for CGPathRef, which lets you create, manipulate and draw bezier paths. These are C, not Objective-C API calls, but they work perfectly fine in an Objective-C application. iPhone OS 3.2 adds UIBezierPath, with wraps these calls, but if you want to target devices running an earlier version of the OS, it wouldn't make sense to use it. One benefit of using the CGPath API is that this is also available as part of CoreGraphics on the Mac, so you're likely to be able to find more sample code out there. A quick Google search returned this hit (http://www.cocos2d-iphone.org/forum/topic/1376 ), which talks about moving sprites along a path and references other info that might be helpful. On Apr 12, 2010, at 11:06 PM, charisse napeÿf1as wrote: I'm a newbie at iphone development and I was wondering if somebody can point out how to create a simple app where I can draw a simple path with loops or curves from point a to b and then make an object follow that path from a to b. Anybody can give me a sample code or something so I can study it? Thanks, Charisse ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: Font Style Names for iPhone/iPad
Yes, but no support for actually doing anything useful with CoreText. Can't comment on eventualities, but let's just say I'm not happy. (Sneezy from pollen, Sleepy from too much coding, Grumpy about lack of text support, but definitely not Happy :-) On 4/14/10 10:10 AM, "Matt Moriarity" wrote: > Core Text is available in 3.2, which I believe is no longer under NDA. > > On Tue, Apr 13, 2010 at 1:04 PM, Kyle Sluder wrote: >> On Apr 13, 2010, at 7:34 AM, Fritz Anderson wrote: >> >>> Has discussion of post-3.1 API been cleared? I understood that the >>> moderator has to expressly say so, and I see no reason not to, but I never >>> saw such a message. Also, the OP wanted a solution that worked for iPhone as >>> well. >> >> Didn't even think about it. I used the Mac Core Text reference. >> >> --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/matt.moriarity%2Bml%40gmail. >> com >> >> This email sent to matt.moriarity...@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: NSNumberFormatter not working for me ?
Actually, setting the formatter behavior does work (it does allow you to use setFormat: to set a format string). The remaining problem is that I don't think NSNumberFormatter allows the arbitray digit-by- digit formatting of numbers that you expect. _murat On Apr 13, 2010, at 8:54 PM, Bill Hernandez wrote: On Apr 13, 2010, at 8:09 PM, Murat Konar wrote: If you don't explicitly set a formatter behavior, you are probably getting the newest behavior "NSNumberFormatterBehavior10_4", and - setFormat: does require the older "NSNumberFormatterBehavior10_0" behavior. That's why your string is being returned unchanged. As far as the formatter is concerned, you have not set a format string. Note also that in your most recently posted code, you set the default behavior for the class *after* you allocate an instance. You should either set the default behavior before creating an instance, or set the behavior on the instance itself. murat, if I call: phoneNumber = [BHUtility bhFormatNumberString:strippedNumber withFormat:@"(###) ###-"]; run [Switching to process 6314] Running… Current language: auto; currently objective-c 2010-04-13 22:48:23.398 Formatter[6314:a0f] [4625] theString = (1234567890) - (gdb) // +-+-+-+-+-+- +-+-+ + (NSString *)bhFormatNumberString:(NSString *)aNumberString withFormat:(NSString *)aFormat { // THIS METHOD DOES NOT WORK [NSNumberFormatter setDefaultFormatterBehavior:NSNumberFormatterBehavior10_0]; NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease]; // NSFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease]; [numberFormatter setFormat:aFormat];// specify just positive values format NSInteger theInt = [aNumberString intValue]; NSNumber *theNum = [NSNumber numberWithInt:theInt]; NSString *theString = (NSString *)[numberFormatter stringFromNumber:theNum]; NSLog(@"[4625] theString = %@", theString); return theString; // +-+-+-+-+-+- +-+-+ } I came up with a better work-aroundthat I posted to the forum. Take a look at it, it really works very well, and is not limited to phone numbers. Thanks a million for trying to help me... Bill Hernandez Plano, Texas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Playing DVD Programmatically?
Maybe not a Cocoa question but I couldn't find any list on lists.apple.com that seems related to that. How can I play a DVD (commercial or not) programmatically, preferably using Cocoa? -Laurent. -- Laurent Daudelin AIM/iChat/Skype:LaurentDaudelin http://nemesys.dyndns.org Logiciels Nemesys Software laurent.daude...@gmail.com Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: Playing DVD Programmatically?
On Apr 14, 2010, at 11:14 AM, Laurent Daudelin wrote: > Maybe not a Cocoa question but I couldn't find any list on lists.apple.com > that seems related to that. > > How can I play a DVD (commercial or not) programmatically, preferably using > Cocoa? The DVD Playback Framework should allow you to do this. It is a C API, but should be usable in a Cocoa application. -- David Duncan Apple DTS Animation and Printing ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: Playing DVD Programmatically?
On Apr 14, 2010, at 11:29, David Duncan wrote: > On Apr 14, 2010, at 11:14 AM, Laurent Daudelin wrote: > >> Maybe not a Cocoa question but I couldn't find any list on lists.apple.com >> that seems related to that. >> >> How can I play a DVD (commercial or not) programmatically, preferably using >> Cocoa? > > > The DVD Playback Framework should allow you to do this. It is a C API, but > should be usable in a Cocoa application. Thanks, David. Completely overlooked that framework, duh! -Laurent. -- Laurent Daudelin AIM/iChat/Skype:LaurentDaudelin http://nemesys.dyndns.org Logiciels Nemesys Software laurent.daude...@gmail.com Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Loading a Custom View made in IB into tabViewItem(s)
Greetings, I have the following problem: *Set up: -I created a Custom View in Interface Builder that holds a number of other controls within it (text boxes, buttons, etc.) -I created a Controller class for that View that I connected to it via the Controller "cube" from the Library in IB -There is a model class that serves as a connection between an external device and the application -In my main application window there is a tabView without tabs at start up *Desired result: -When the application starts the user would click a button to create a new connection to an external device -The program would connect, create a new tabViewItem and add it to the tabView (up to now all works great) -Custom View should be loaded into the tabViewItem providing the device interaction interface (This is where things don't happen as desired) ~The reason I cannot just place the controls into the main window from the get-go is that there would be multiple devices that the user can be connected to all at once. Interactions would be all the same (since they are all same devices with different IDs). So, my question is - how can I get that view loading into those tabs? Should I also create a class in my project that derives from the NSView for that custom view object? If so, how would I connect/bind/? that class with the custom view I made in IB? I would really appreciate some help on this - I've been "googling" it & trying different approaches I could find for a couple of days now but to no avail :( The examples are mostly about creating a custom view in code and drawing lines and curves to it at run time. Thank you. A. __ The new Internet Explorer® 8 - Faster, safer, easier. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Time zone Issue with NSDate in Snow Leopard
Hi All, In SnowLeopard I am facing one issue with time zone change. Once we change time zone after launching application, this time zone change we can not get it inside our application using *NSDate* until*Quit* and *Re-launch. *In Leopard it works as per our expectation. In Leopard NSDate return date with current time zone which we selected for machine. Thanks & Regards, Joby Abraham. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
base64Binary
Hi everyone, I have some problem. I'm writing a web service client and one of my xml request require a data encoded as base64Binary. I'm using NSData type in my application but data are encoded as base64. Do you know any solution? Best regards, Bartosz Bialecki ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Unrecognized selector sent to NSMapTable
Hi, I keep getting segfaults and "unrecognized selector" exceptions in my garbage-collected code running on 10.5.8, while the same code works fine on 10.6.3 (stack traces posed below). It doesn't help that the crashes/exceptions happen deep in the framework code and I can't find any documentation on it (NSFireDelayedPerform? NSClassicMap?) Has anyone seen something like this before? Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0xfc7f4e78 0x91877f18 in -[NSArray indexOfObjectIdenticalTo:] () (gdb) bt #0 0x91877f18 in -[NSArray indexOfObjectIdenticalTo:] () #1 0x94124c30 in -[NSActionBinder _performActionWithCommitEditing:didCommit:contextInfo:] () #2 0x9438a960 in _NSSendCommitEditingSelector () #3 0x9419c7c4 in -[NSController _controllerEditor:didCommit:contextInfo:] () #4 0x918889ac in __invoking___ () #5 0x91888234 in -[NSInvocation invoke] () #6 0x918882dc in -[NSInvocation invokeWithTarget:] () #7 0x96b64eb4 in __NSFireDelayedPerform () #8 0x9181581c in CFRunLoopRunSpecific () #9 0x93845b18 in RunCurrentEventLoopInMode () #10 0x9384593c in ReceiveNextEventCommon () #11 0x9384577c in BlockUntilNextEventMatchingListInMode () #12 0x93de5248 in _DPSNextEvent () #13 0x93de4c00 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] () #14 0x93dde8a0 in -[NSApplication run] () #15 0x93daf29c in NSApplicationMain () #16 0x23e4 in start () -- *** -[NSClassicMapTable indexOfObjectIdenticalTo:]: unrecognized selector sent to instance 0x10c6240 Breakpoint 1, 0x936934c0 in objc_exception_throw () (gdb) bt #0 0x936934c0 in objc_exception_throw () #1 0x91889eb8 in -[NSObject doesNotRecognizeSelector:] () #2 0x918884b4 in ___forwarding___ () #3 0x91888748 in __forwarding_prep_0___ () #4 0x94124c30 in -[NSActionBinder _performActionWithCommitEditing:didCommit:contextInfo:] () #5 0x9438a960 in _NSSendCommitEditingSelector () #6 0x9419c7c4 in -[NSController _controllerEditor:didCommit:contextInfo:] () #7 0x918889ac in __invoking___ () #8 0x91888234 in -[NSInvocation invoke] () #9 0x918882dc in -[NSInvocation invokeWithTarget:] () #10 0x96b64eb4 in __NSFireDelayedPerform () #11 0x9181581c in CFRunLoopRunSpecific () #12 0x93845b18 in RunCurrentEventLoopInMode () #13 0x9384593c in ReceiveNextEventCommon () #14 0x9384577c in BlockUntilNextEventMatchingListInMode () #15 0x93de5248 in _DPSNextEvent () #16 0x93de4c00 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] () #17 0x93dde8a0 in -[NSApplication run] () #18 0x93daf29c in NSApplicationMain () #19 0x23e4 in start () Thanks, 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
Efficiently iterating files on the iPhone
Hi everyone, I'm trying to find a fast and efficient way to iterate a folder on the iPhone. On the Mac, I'd create an FSIterator and use FSGetCatalogInfoBulk (so I can retrieve permissions, file type, resource/data fork size, etc). However, FSIterator and FSGetCatalogInfo* are part of the CoreServices framework, which doesn't appear to exist on the device (although it's in the simulator SDK). If I have to, I can use the NSFileManager APIs, but then I'd have to grab the entire directory listing at once (instead of getting it in chunks), and then iteratively ask for each item's attributes. It seems rather inefficient, and I want to make this as efficient as possible. (NSFileManager also does not include resource forks) Any suggestions on how I can iterate a directory and get file information at the same time? Thanks, Dave DeLong 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: NSNumberFormatter not working for me ?
On Apr 14, 2010, at 1:04 PM, Murat Konar wrote: > Actually, setting the formatter behavior does work (it does allow you to use > setFormat: to set a format string). The remaining problem is that I don't > think NSNumberFormatter allows the arbitray digit-by-digit formatting of > numbers that you expect. > > _murat murat, Thank You for your effort... The result that setting : [NSNumberFormatter setDefaultFormatterBehavior:NSNumberFormatterBehavior10_0]; is shown on the next line, hardly what one would expect ? > (1234567890) - I've worked with lots of number formatters over the years, and that is what they do, format numbers into strings, any kind of string... I looked at the header file for NSNumberFormatter, and there seem to be 9,000,000+ methods, it is amazing. Buried in there, there has to be a simple way to format a string, that I am overlooking ? If you look the simple formatter I wrote up last night, it will format a string digits any way imaginable. I just ran the little test app I created last night and you can see the results below : I use 'strippedNumber', because by the time I call this routine all the junk non-digits have been stripped out... Bill Hernandez Plano, Texas I created a simple NSTextView that the output gets sent to: IBOutlet NSTextView *mainTextView; CALLED : NSString *phoneNumber; phoneNumber = [BHUtility bhFormatNumberString:strippedNumber withFormat:format]; [4751] strippedNumber = @"1234567890" format = @"(###) ###-" result = @"(123) 456-7890" [4752] strippedNumber = @"1234567890" format = @"###.###." result = @"123.456.7890" [4753] strippedNumber = @"1234567890" format = @"<[###.###.]>" result = @"<[123.456.7890]>" [4754] strippedNumber = @"12345678909889" format = @"(###) ###- [extension ]" result = @"(123) 456-7890 [extension 9889]" [4755] strippedNumber = @"12345678909889" format = @"Weekends : (###) ###- [extension ]" result = @"Weekends : (123) 456-7890 [extension 9889]" [4756] strippedNumber = @"12345678909889" format = @"Social Security : ###-##-###" result = @"Social Security : 123-45-678" You can see on the line above, that if the user enters more digits, than the format requires, the method simply skips the rest. This could be good and bad, but you can trap for that ahead of time... I would think the Apple Engineers could have come up with one more method, and had 9,000,001 in the class as a last resort. I bet the answer is in that class, I just can't find it, and I don't know enough Cocoa to come out of the rain. I am sure an answer will turn up... I also understand that I don't have big time error checking. and for me, this only has to work in a very limited scope, and does not need to be as robust as what comes from the factory. All that having been said, the work-around works really slick... I am sure that I am just overlooking something really simple, but I can't figure out what it is... // +-+-+-+-+-+-+-+-+ // BHUtility.h // Formatter // // Created by Bill Hernandez on 4/13/2010. // +-+-+-+-+-+-+-+-+ #import #import "RegexKitLite.h"// Not required for this demo, you can comment it out @interface BHUtility : NSObject { } // +-+-+-+-+-+-+-+-+ // [4827] ( BEGIN ) Working with Strings // +-+-+-+-+-+-+-+-+ /* * THIS METHOD DOES NOT WORK, NOTICE IT HAS BEEN RENAMED AS UNUSABLE (FOR NOW) * * I left it here in case NSNumberFormatter and setFormat ever work in this area * I couldn't figure out how to make it work, so I came up with a great work-around * at least in my opinion, doesn't sound very humble, I apologize for that... * * But in reality, it is a heck of a lot easier than using NSNumberFormatter, and * that's a fact... */ + (NSString *)unusable_bhFormatNumberString:(NSString *)aNumberString withFormat:(NSString *)aFormat; // +-+-+-+-+-+-+-+-+ /* * THIS IS THE MAIN NUMBER FORMATTER * * A less cryptic Objective CLike method, does the same as below, * this is more for the mere mortal Objective C afficionado... */ + (NSString *)bhFormatNumberString:(NSString *)aNumberString withFormat:(NSString *)aFormat; // +-+-+-+-+-+-+-+-+ /* * A more cryptic CLike method, does the same as above, but * is easier to read for the C afficionado... * * for the people that don't like long variable names, I failed in a way though, * since I didn't use any bufptr(s), even so it's a little less descriptive */ + (NSString *)bhFormatNumberStringButMoreCLike:(N
Re: base64Binary
Hi Bialecki, for base64 encoding/decoding you can use openSSL Library which providing by MAC OS. I can give you code snippets for encoding and decoding string. #include #include - (NSString *)base64EncodedString { // Construct an OpenSSL context BIO *context = BIO_new(BIO_s_mem()); // Tell the context to encode base64 BIO *command = BIO_new(BIO_f_base64()); context = BIO_push(command, context); // Encode all the data BIO_write(context, [self bytes], [self length]); BIO_flush(context); // Get the data out of the context char *outputBuffer; long outputLength = BIO_get_mem_data(context, &outputBuffer); NSString *encodedString = [NSString stringWithCString:outputBuffer length:outputLength]; BIO_free_all(context); return encodedString; } + (NSData *)dataByDase64DecodingString:(NSString *)decode { decode = [decode stringByAppendingString:@"\n"]; NSData *data = [decode dataUsingEncoding:NSASCIIStringEncoding]; // Construct an OpenSSL context BIO *command = BIO_new(BIO_f_base64()); BIO *context = BIO_new_mem_buf((void *)[data bytes], [data length]); // Tell the context to encode base64 context = BIO_push(command, context); // Encode all the data NSMutableData *outputData = [NSMutableData data]; #define BUFFSIZE 256 int len; char inbuf[BUFFSIZE]; while ((len = BIO_read(context, inbuf, BUFFSIZE)) > 0) { [outputData appendBytes:inbuf length:len]; } BIO_free_all(context); [data self]; // extend GC lifetime of data to here return outputData; } 2010/4/14 Bartosz Bialecki > Hi everyone, > I have some problem. I'm writing a web service client and one of my xml > request require a data encoded as base64Binary. I'm using NSData type in my > application but data are encoded as base64. Do you know any solution? > > Best regards, > Bartosz Bialecki > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > > http://lists.apple.com/mailman/options/cocoa-dev/jobyabraham1983%40gmail.com > > This email sent to jobyabraham1...@gmail.com > -- Thanks & Regards, Joby Abraham. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: Efficiently iterating files on the iPhone
On Apr 14, 2010, at 12:39 PM, Dave DeLong wrote: If I have to, I can use the NSFileManager APIs, but then I'd have to grab the entire directory listing at once (instead of getting it in chunks), and then iteratively ask for each item's attributes. It seems rather inefficient, and I want to make this as efficient as possible. Have you actually written the code and measured how long it takes? Or are you guessing? How many directories and files do you expect this code to iterate over? Also keep in mind that the iPhone uses an SSD, with zero seek time. Keep in mind the programming principle: "Do the simplest thing that could possibly work" (and then measure and optimize and iterate.) —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Efficiently iterating files on the iPhone
On 14 Apr 2010, at 12:39 PM, Dave DeLong wrote: > I'm trying to find a fast and efficient way to iterate a folder on the > iPhone. On the Mac, I'd create an FSIterator and use FSGetCatalogInfoBulk > (so I can retrieve permissions, file type, resource/data fork size, etc). > However, FSIterator and FSGetCatalogInfo* are part of the CoreServices > framework, which doesn't appear to exist on the device (although it's in the > simulator SDK). The simulator SDK doesn't reflect what actually happens on the device. Trust what's in (or what isn't in) the device SDK. > If I have to, I can use the NSFileManager APIs, but then I'd have to grab the > entire directory listing at once (instead of getting it in chunks), and then > iteratively ask for each item's attributes. It seems rather inefficient, and > I want to make this as efficient as possible. (NSFileManager also does not > include resource forks) You're on the iPhone; resource forks aren't something you need to worry about - even though the filesystem may be HFS+, it's not as if you can read a resource fork on the device. As Jens implies, this sounds like you're prematurely optimizing a bit. > Any suggestions on how I can iterate a directory and get file information at > the same time? The current implementation of NSFileManager on the iPhone should be pretty efficient about the available information because it's basically using what's available in the stat() block and nothing else. You should be fine in just using NSFileManager and asking for fileAttributes using an NSDirectoryEnumerator. And as that gets faster, you'll get faster. If you're that worried about it, though, it implies you have a ton of files you're iterating over. Is that really the case? .chris -- Chris Parker iPhone Frameworks Apple, Inc. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Efficiently iterating files on the iPhone
I don't know how many files I'll be iterating, since I'm working on a library that will (hopefully) end up included in many applications. My reason for wanting to optimize this as much as possible is so that it's as least invasive as possible to other developers who use this. But, judging from the responses, it sounds like NSFileManager is the way to go. Thanks! Dave On Apr 14, 2010, at 2:42 PM, Chris Parker wrote: > You should be fine in just using NSFileManager and asking for fileAttributes > using an NSDirectoryEnumerator. And as that gets faster, you'll get faster. > If you're that worried about it, though, it implies you have a ton of files > you're iterating over. Is that really the case? 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: base64Binary
Google provide some class to do that too. See GTMBase64 classes at http://code.google.com/p/google-toolbox-for-mac/source/browse/#svn/trunk/Foundation Le 14 avr. 2010 à 22:00, joby abraham a écrit : > Hi Bialecki, > > for base64 encoding/decoding you can use openSSL Library which providing by > MAC OS. > > I can give you code snippets for encoding and decoding string. > > #include > #include > > - (NSString *)base64EncodedString > { >// Construct an OpenSSL context >BIO *context = BIO_new(BIO_s_mem()); > >// Tell the context to encode base64 >BIO *command = BIO_new(BIO_f_base64()); >context = BIO_push(command, context); > >// Encode all the data >BIO_write(context, [self bytes], [self length]); >BIO_flush(context); > >// Get the data out of the context >char *outputBuffer; >long outputLength = BIO_get_mem_data(context, &outputBuffer); >NSString *encodedString = [NSString >stringWithCString:outputBuffer >length:outputLength]; > >BIO_free_all(context); > >return encodedString; > } > > > + (NSData *)dataByDase64DecodingString:(NSString *)decode > { >decode = [decode stringByAppendingString:@"\n"]; >NSData *data = [decode dataUsingEncoding:NSASCIIStringEncoding]; > >// Construct an OpenSSL context >BIO *command = BIO_new(BIO_f_base64()); >BIO *context = BIO_new_mem_buf((void *)[data bytes], [data length]); > >// Tell the context to encode base64 >context = BIO_push(command, context); > >// Encode all the data >NSMutableData *outputData = [NSMutableData data]; > >#define BUFFSIZE 256 >int len; >char inbuf[BUFFSIZE]; >while ((len = BIO_read(context, inbuf, BUFFSIZE)) > 0) >{ >[outputData appendBytes:inbuf length:len]; >} > >BIO_free_all(context); >[data self]; // extend GC lifetime of data to here > >return outputData; > } > > > 2010/4/14 Bartosz Bialecki > >> Hi everyone, >> I have some problem. I'm writing a web service client and one of my xml >> request require a data encoded as base64Binary. I'm using NSData type in my >> application but data are encoded as base64. Do you know any solution? >> >> Best regards, >> Bartosz Bialecki >> ___ >> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >> >> Please do not post admin requests or moderator comments to the list. >> Contact the moderators at cocoa-dev-admins(at)lists.apple.com >> >> Help/Unsubscribe/Update your Subscription: >> >> http://lists.apple.com/mailman/options/cocoa-dev/jobyabraham1983%40gmail.com >> >> This email sent to jobyabraham1...@gmail.com >> > > > > -- > Thanks & Regards, > Joby Abraham. > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > 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 -- Jean-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
Re: base64Binary
Hi Bialecki, It always better use library which provided by MAC OS. Thanks& regards, Joby Abraham. On Thu, Apr 15, 2010 at 02:17, Jean-Daniel Dupas wrote: > Google provide some class to do that too. > > See GTMBase64 classes at > http://code.google.com/p/google-toolbox-for-mac/source/browse/#svn/trunk/Foundation > > Le 14 avr. 2010 à 22:00, joby abraham a écrit : > > > Hi Bialecki, > > > > for base64 encoding/decoding you can use openSSL Library which providing > by > > MAC OS. > > > > I can give you code snippets for encoding and decoding string. > > > > #include > > #include > > > > - (NSString *)base64EncodedString > > { > >// Construct an OpenSSL context > >BIO *context = BIO_new(BIO_s_mem()); > > > >// Tell the context to encode base64 > >BIO *command = BIO_new(BIO_f_base64()); > >context = BIO_push(command, context); > > > >// Encode all the data > >BIO_write(context, [self bytes], [self length]); > >BIO_flush(context); > > > >// Get the data out of the context > >char *outputBuffer; > >long outputLength = BIO_get_mem_data(context, &outputBuffer); > >NSString *encodedString = [NSString > >stringWithCString:outputBuffer > >length:outputLength]; > > > >BIO_free_all(context); > > > >return encodedString; > > } > > > > > > + (NSData *)dataByDase64DecodingString:(NSString *)decode > > { > >decode = [decode stringByAppendingString:@"\n"]; > >NSData *data = [decode dataUsingEncoding:NSASCIIStringEncoding]; > > > >// Construct an OpenSSL context > >BIO *command = BIO_new(BIO_f_base64()); > >BIO *context = BIO_new_mem_buf((void *)[data bytes], [data length]); > > > >// Tell the context to encode base64 > >context = BIO_push(command, context); > > > >// Encode all the data > >NSMutableData *outputData = [NSMutableData data]; > > > >#define BUFFSIZE 256 > >int len; > >char inbuf[BUFFSIZE]; > >while ((len = BIO_read(context, inbuf, BUFFSIZE)) > 0) > >{ > >[outputData appendBytes:inbuf length:len]; > >} > > > >BIO_free_all(context); > >[data self]; // extend GC lifetime of data to here > > > >return outputData; > > } > > > > > > 2010/4/14 Bartosz Bialecki > > > >> Hi everyone, > >> I have some problem. I'm writing a web service client and one of my xml > >> request require a data encoded as base64Binary. I'm using NSData type in > my > >> application but data are encoded as base64. Do you know any solution? > >> > >> Best regards, > >> Bartosz Bialecki > >> ___ > >> > >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > >> > >> Please do not post admin requests or moderator comments to the list. > >> Contact the moderators at cocoa-dev-admins(at)lists.apple.com > >> > >> Help/Unsubscribe/Update your Subscription: > >> > >> > http://lists.apple.com/mailman/options/cocoa-dev/jobyabraham1983%40gmail.com > >> > >> This email sent to jobyabraham1...@gmail.com > >> > > > > > > > > -- > > Thanks & Regards, > > Joby Abraham. > > ___ > > > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > > > Please do not post admin requests or moderator comments to the list. > > 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 > > -- Jean-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
Re: base64Binary
Me too for Apple frameworks, but not for libcrypto and other bsd libraries. Using them for cross OS dev (compile using 10.6 SDK and deploy on 10.4) is a mess. They don't use availability macros, and weak linking and so are error prone and sometime impossible to link properly (especially libcrypto). Le 14 avr. 2010 à 22:58, joby abraham a écrit : > Hi Bialecki, > > It always better use library which provided by MAC OS. > > Thanks& regards, > Joby Abraham. > > On Thu, Apr 15, 2010 at 02:17, Jean-Daniel Dupas > wrote: > Google provide some class to do that too. > > See GTMBase64 classes at > http://code.google.com/p/google-toolbox-for-mac/source/browse/#svn/trunk/Foundation > > Le 14 avr. 2010 à 22:00, joby abraham a écrit : > > > Hi Bialecki, > > > > for base64 encoding/decoding you can use openSSL Library which providing by > > MAC OS. > > > > I can give you code snippets for encoding and decoding string. > > > > #include > > #include > > > > - (NSString *)base64EncodedString > > { > >// Construct an OpenSSL context > >BIO *context = BIO_new(BIO_s_mem()); > > > >// Tell the context to encode base64 > >BIO *command = BIO_new(BIO_f_base64()); > >context = BIO_push(command, context); > > > >// Encode all the data > >BIO_write(context, [self bytes], [self length]); > >BIO_flush(context); > > > >// Get the data out of the context > >char *outputBuffer; > >long outputLength = BIO_get_mem_data(context, &outputBuffer); > >NSString *encodedString = [NSString > >stringWithCString:outputBuffer > >length:outputLength]; > > > >BIO_free_all(context); > > > >return encodedString; > > } > > > > > > + (NSData *)dataByDase64DecodingString:(NSString *)decode > > { > >decode = [decode stringByAppendingString:@"\n"]; > >NSData *data = [decode dataUsingEncoding:NSASCIIStringEncoding]; > > > >// Construct an OpenSSL context > >BIO *command = BIO_new(BIO_f_base64()); > >BIO *context = BIO_new_mem_buf((void *)[data bytes], [data length]); > > > >// Tell the context to encode base64 > >context = BIO_push(command, context); > > > >// Encode all the data > >NSMutableData *outputData = [NSMutableData data]; > > > >#define BUFFSIZE 256 > >int len; > >char inbuf[BUFFSIZE]; > >while ((len = BIO_read(context, inbuf, BUFFSIZE)) > 0) > >{ > >[outputData appendBytes:inbuf length:len]; > >} > > > >BIO_free_all(context); > >[data self]; // extend GC lifetime of data to here > > > >return outputData; > > } > > > > > > 2010/4/14 Bartosz Bialecki > > > >> Hi everyone, > >> I have some problem. I'm writing a web service client and one of my xml > >> request require a data encoded as base64Binary. I'm using NSData type in my > >> application but data are encoded as base64. Do you know any solution? > >> > >> Best regards, > >> Bartosz Bialecki > >> ___ > >> > >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > >> > >> Please do not post admin requests or moderator comments to the list. > >> Contact the moderators at cocoa-dev-admins(at)lists.apple.com > >> > >> Help/Unsubscribe/Update your Subscription: > >> > >> http://lists.apple.com/mailman/options/cocoa-dev/jobyabraham1983%40gmail.com > >> > >> This email sent to jobyabraham1...@gmail.com > >> > > > > > > > > -- > > Thanks & Regards, > > Joby Abraham. > > ___ > > > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > > > Please do not post admin requests or moderator comments to the list. > > 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 > > -- Jean-Daniel > > > > > > > -- Jean-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
Re: NSNumberFormatter not working for me ?
Bill Hernandez wrote: I've worked with lots of number formatters over the years, and that is what they do, format numbers into strings, any kind of string... I looked at the header file for NSNumberFormatter, and there seem to be 9,000,000+ methods, it is amazing. Buried in there, there has to be a simple way to format a string, that I am overlooking ? If you look the simple formatter I wrote up last night, it will format a string digits any way imaginable. Your code formats strings (more specifically, characters in strings). It does not format numbers, as such. By "number" I mean a binary numeric value (floating-point or integer), or possibly NSNumber or NSDecimalNumber. All your "number" parameters are actually of the NSString* type, not of a numeric type. The fact that the string contains digits is incidental. In a sense, converting a numeric value to NSString* is already a "formatting" operation, or at least a conversion operation. Your code would work just as well if you passed it an alphabetic string, or one containing punctuation marks. strippedNumber = @"SueMeTomorrow" format = @"Social Security : ###-##-###" result = @"Social Security : Sue-Me-Tom" I'm not saying the digit-string isn't relevant to what you're doing, only that what you seem to think of as a number is, in fact, a string that happens to contain a series of digit characters. I think that was a point an earlier reply was trying to make: NSNumberFormatter is for numeric values (NSNumber, in particular), not string values that happen to contain digits. -- 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
Question about -awakeAfterusingCoder:
Hi all, Got a slightly awkward problem I'm trying to find a good solution to. I have a number of objects forming a class hierarchy where e.g. C subclasses B which subclasses A. A has a 'locked' property which locks it preventing changes to several other properties. B and C add further properties some of which also check 'locked' in their setters and become no-ops if locked is true. When objects are dearchived, 'locked' is one of the dearchived properties of A. But when B and C properties are subsequently dearchived, if locked was YES, then many of these dearchived properties, which are set through the relevant setters, are ignored. Disaster ensues. I can see a number of solutions: A. When checking for locked in a setter, do something like: if( locked && !currentlyDearchiving ) return; But that needs lots of changes and some hackery to flag when dearchiving is in progress. B. For each implementation of -initWithCoder:, save the locked state, set it to NO, dearchive, then restore the saved lock state. That's slightly better, but still requires that all subclasses remember to do this and is a biggish change to the code. I'd prefer a way to handle this entirely in the base class, A. So I'm wondering if I can use -awakeAfterUsingCoder:. Is it safe to ask the coder to decode a value at that time? Since it runs after all subclasses have been initedWithCoder, it ought to be the right time to finally set the true state of the lock. I have misgivings however that this is not its intended purpose. If that's not allowed or would be bad for other reasons, is there a way to defer it somehow, for example by posting a -performAfterDelay on self to set the lock state - that would only run after all dearchiving completed I believe. Or something else? --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
Xcode 3.23 broke my code signing
Project that built fine for weeks fails to pass validation, won't run when installed. Ran Xcode uninstall, reinstalled from scratch, same deal. Other than randomly trying stuff, does anyone have a known working procedure for fixing this??? Hard to think of a less productive way to waste time.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: NSNumberFormatter not working for me ?
On Apr 14, 2010, at 5:25 PM, Greg Guerin wrote: > Your code formats strings (more specifically, characters in strings). It > does not format numbers, as such. This is the work-around that I did because I could not make do with NSNumberFormatter. > By "number" I mean a binary numeric value (floating-point or integer), or > possibly NSNumber or NSDecimalNumber. I've been programming the mac since 1987 pretty much full-time. so I promise you, I am not confused at all about what a number is, and isn't... > All your "number" parameters are actually of the NSString* type, not of a > numeric type. The fact that the string contains digits is incidental. In a > sense, converting a numeric value to NSString* is already a "formatting" > operation, or at least a conversion operation. I think you missed the earlier messages. You are probably looking at the converter that I wrote as a work-around, which is basically a numeric string formatter. > Your code would work just as well if you passed it an alphabetic string, or > one containing punctuation marks. > > strippedNumber = @"SueMeTomorrow" > format = @"Social Security : ###-##-###" > result = @"Social Security : Sue-Me-Tom" > > I'm not saying the digit-string isn't relevant to what you're doing, only > that what you seem to think of as a number is, in fact, a string that happens > to contain a series of digit characters. I think that was a point an earlier > reply was trying to make: NSNumberFormatter is for numeric values (NSNumber, > in particular), not string values that happen to contain digits. I think you missed the previous message, where someone else made your same incorrect assumption, only to have that cleared up by Jens Alfke. Jens picked up that I was actually using an NSNumber with the NSNumberFormatter. Please look at the comment from Jens Alfke , and the three lines of code below, they should clear that up for you. > only that what you seem to think of as a number is I promise you I know what a number is... This got answered a while back... On Apr 13, 2010, at 4:55 PM, Jens Alfke wrote: > On Apr 13, 2010, at 2:49 PM, Keary Suska wrote: > >> You are asking the NSNumberFormatters to format a string, which it does not >> do (hence the class name). > > No he isn't. Viz: > > NSInteger theInt = [aNumberString intValue]; > NSNumber *theNum = [NSNumber numberWithInt:theInt]; > NSString *theString = (NSString *)[numberFormatter stringFromNumber:theNum]; > > —Jens Here's the original piece of code that you must have missed, please read the code carefully. I added two comments in the code in case you missed the NSNumber line. // <--- NSUInteger (look for these below) // <--- NSNumber (look for these below) // +-+-+-+-+-+-+-+-+ - (void)awakeFromNib { // I have already run a routine to strip all non digits by this time NSString *strippedNumber = @"1234567890"; NSString *phoneNumber; NSString *format; format = @"(###) ###-"; phoneNumber = [BHUtility bhFormatNumberString:strippedNumber withFormat:format]; } // +-+-+-+-+-+-+-+-+ // +-+-+-+-+-+-+-+-+ + (NSString *)unusable_bhFormatNumberString:(NSString *)aNumberString withFormat:(NSString *)aFormat { // THIS METHOD DOES NOT WORK, WITH OR WITHOUT THE NEXT LINE // YIELDS INCORRECT RESULTS : @"(1234567890) -" [NSNumberFormatter setDefaultFormatterBehavior:NSNumberFormatterBehavior10_0]; NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease]; // NSFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease]; [numberFormatter setFormat:aFormat];// specify just positive values format NSUInteger theInt = [aNumberString intValue];// <--- NSUInteger NSNumber *theNum = [NSNumber numberWithInt:theInt];// <--- NSNumber NSString *theString = (NSString *)[numberFormatter stringFromNumber:theNum]; NSLog(@"[4625] theString = %@", theString); return theString; // +-+-+-+-+-+-+-+-+ } // +-+-+-+-+-+-+-+-+ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to a
Re: NSNumberFormatter not working for me ?
On 15/04/2010, at 11:38 AM, Bill Hernandez wrote: > // I have already run a routine to strip all non digits by this time Don't forget that phone numbers can start with '+' to mean 'whatever the international dialling prefix for your country is'. --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: Question about -awakeAfterusingCoder:
I've always avoided using setters in init methods for exactly the problem you've run into. A setter's behavior can depend on an object's state, and by definition, the object's state is not really properly setup *during* init. _murat On Apr 14, 2010, at 6:23 PM, Graham Cox wrote: Hi all, Got a slightly awkward problem I'm trying to find a good solution to. I have a number of objects forming a class hierarchy where e.g. C subclasses B which subclasses A. A has a 'locked' property which locks it preventing changes to several other properties. B and C add further properties some of which also check 'locked' in their setters and become no-ops if locked is true. When objects are dearchived, 'locked' is one of the dearchived properties of A. But when B and C properties are subsequently dearchived, if locked was YES, then many of these dearchived properties, which are set through the relevant setters, are ignored. Disaster ensues. I can see a number of solutions: A. When checking for locked in a setter, do something like: if( locked && !currentlyDearchiving ) return; But that needs lots of changes and some hackery to flag when dearchiving is in progress. B. For each implementation of -initWithCoder:, save the locked state, set it to NO, dearchive, then restore the saved lock state. That's slightly better, but still requires that all subclasses remember to do this and is a biggish change to the code. I'd prefer a way to handle this entirely in the base class, A. So I'm wondering if I can use -awakeAfterUsingCoder:. Is it safe to ask the coder to decode a value at that time? Since it runs after all subclasses have been initedWithCoder, it ought to be the right time to finally set the true state of the lock. I have misgivings however that this is not its intended purpose. If that's not allowed or would be bad for other reasons, is there a way to defer it somehow, for example by posting a - performAfterDelay on self to set the lock state - that would only run after all dearchiving completed I believe. Or something else? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: NSNumberFormatter not working for me ?
I think Greg's point is that NSNumberFormatter is designed to format numbers which represent quantities. A phone number not a quantity, it's just a string of characters which happen to be digits. _murat On Apr 14, 2010, at 6:38 PM, Bill Hernandez wrote: On Apr 14, 2010, at 5:25 PM, Greg Guerin wrote: Your code formats strings (more specifically, characters in strings). It does not format numbers, as such. This is the work-around that I did because I could not make do with NSNumberFormatter. By "number" I mean a binary numeric value (floating-point or integer), or possibly NSNumber or NSDecimalNumber. I've been programming the mac since 1987 pretty much full-time. so I promise you, I am not confused at all about what a number is, and isn't... All your "number" parameters are actually of the NSString* type, not of a numeric type. The fact that the string contains digits is incidental. In a sense, converting a numeric value to NSString* is already a "formatting" operation, or at least a conversion operation. I think you missed the earlier messages. You are probably looking at the converter that I wrote as a work-around, which is basically a numeric string formatter. Your code would work just as well if you passed it an alphabetic string, or one containing punctuation marks. strippedNumber = @"SueMeTomorrow" format = @"Social Security : ###-##-###" result = @"Social Security : Sue-Me-Tom" I'm not saying the digit-string isn't relevant to what you're doing, only that what you seem to think of as a number is, in fact, a string that happens to contain a series of digit characters. I think that was a point an earlier reply was trying to make: NSNumberFormatter is for numeric values (NSNumber, in particular), not string values that happen to contain digits. I think you missed the previous message, where someone else made your same incorrect assumption, only to have that cleared up by Jens Alfke. Jens picked up that I was actually using an NSNumber with the NSNumberFormatter. Please look at the comment from Jens Alfke , and the three lines of code below, they should clear that up for you. only that what you seem to think of as a number is I promise you I know what a number is... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: Question about -awakeAfterusingCoder:
On 15/04/2010, at 11:48 AM, Murat Konar wrote: > I've always avoided using setters in init methods for exactly the problem > you've run into. A setter's behavior can depend on an object's state, and by > definition, the object's state is not really properly setup *during* init. I agree in general, and for other -init methods, but for dearchiving using setters is usually a huge win in not duplicating code, particularly for more complex properties such as composition with other objects, and for not having to think about memory management (setters are the only place where other objects are retained & released apart from init and dealloc). That might be a self-delusion though, and maybe this is the more fundamental problem. It's a huge thing to change now though, and 'locked' is the only property that interacts with others. On 15/04/2010, at 11:23 AM, Graham Cox wrote: > So I'm wondering if I can use -awakeAfterUsingCoder:. Is it safe to ask the > coder to decode a value at that time? Since it runs after all subclasses have > been initedWithCoder, it ought to be the right time to finally set the true > state of the lock. I have misgivings however that this is not its intended > purpose. Having tried this, it works perfectly... I'm still a bit leery that it's an abuse though. --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
programmitically creating nstextfield
Would someone please tell me why this text field will not show. It is driving me spastic. The window and text field are valid. And there are no errors. The window shows but the text field does not. relativeToWindow is valid. NSRect w=[relativeToWindow frame]; NSRect r={{NSMaxX(w)-96, NSMaxY(w)-ToolbarHeightForWindow(relativeToWindow) - titleBarHeight(relativeToWindow)-24}, {256, 64}}; window=[[NSWindow alloc] initWithContentRect:r styleMask:0 backing:NSBackingStoreRetained defer:NO]; //[window setBackgroundColor:[NSColor redColor]]; [window makeKeyAndOrderFront:self]; //[window setAlphaValue:0.3]; [relativeToWindow addChildWindow:window ordered:NSWindowAbove]; [window setLevel:NSFloatingWindowLevel]; f.origin.x=4; f.origin.y=4; f.size.width=128; f.size.height=32; textInfo=[[NSTextField alloc] initWithFrame:f]; [textInfo setSelectable:NO]; NSFont* font=[NSFont fontWithName:@"Times-Roman" size:12]; [textInfo setFont:font]; [textInfo setStringValue:@"hello world"]; [textInfo setBackgroundColor:[NSColor blueColor]]; [[window contentView] addSubview:textInfo]; ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: programmitically creating nstextfield
On 15/04/2010, at 2:24 PM, mark wrote: Would someone please tell me why this text field will not show. It is driving me spastic. The window and text field are valid. And there are no errors. The window shows but the text field does not. relativeToWindow is valid. NSRect w=[relativeToWindow frame]; NSRect r={{NSMaxX(w)-96, NSMaxY(w)- ToolbarHeightForWindow(relativeToWindow) - titleBarHeight(relativeToWindow)-24}, {256, 64}}; NSRect r = NSMakeRect(... ); window=[[NSWindow alloc] initWithContentRect:r styleMask:0 backing:NSBackingStoreRetained defer:NO]; //[window setBackgroundColor:[NSColor redColor]]; [window makeKeyAndOrderFront:self]; //[window setAlphaValue:0.3]; [relativeToWindow addChildWindow:window ordered:NSWindowAbove]; [window setLevel:NSFloatingWindowLevel]; f.origin.x=4; f.origin.y=4; f.size.width=128; f.size.height=32; How is 'f' created? Is 'f' valid? textInfo=[[NSTextField alloc] initWithFrame:f]; [textInfo setSelectable:NO]; NSFont* font=[NSFont fontWithName:@"Times-Roman" size:12]; [textInfo setFont:font]; [textInfo setStringValue:@"hello world"]; [textInfo setBackgroundColor:[NSColor blueColor]]; [[window contentView] addSubview:textInfo]; ___ Are the values of relativeToWindow sane? Ron ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: programmitically creating nstextfield
--Jens {via iPad} On Apr 14, 2010, at 9:48 PM, Ron Fleckner wrote: > >> NSRect r={{NSMaxX(w)-96, NSMaxY(w)-ToolbarHeightForWindow(relativeToWindow) >> -titleBarHeight(relativeToWindow)-24}, >> {256, 64}}; > > NSRect r = NSMakeRect(... ); The original syntax is correct too. Its using regular C syntax for initializing a struct literal. > >> f.origin.x=4; >> >> f.origin.y=4; >> f.size.width=128; >> f.size.height=32; > > How is 'f' created? Is 'f' valid? f must be an NSRect, so it doesn't get created, and those statements fully initialize it. > >> >> [[window contentView] addSubview:textInfo] Try calling -setNeedsDisplayInRect: f on the superview to get the subview to be drawn. --Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
iPhone: A memory leak I can't explain
Hi, in my app I'm accessing the photo library (in my opinion exactly as in sample programs I have seen from Apple). When leak-testing the app on the iPhone using Instrument the following leak is being reported (see stack trace) and I don't know the root cause. Does anybody has seen this before perhaps and knows the answer? Stack trace excerpt (*): ... MyApp main UIKit UIApplicationMain ... GraphicsServices GSEventRunModal ... MusicLibraryMLPhotoLibrary albums MusicLibraryMLPhotoLibrary _loadImageLibrary MusicLibraryReadITImageDB MusicLibraryMemNewPtrClear libSystem.B.dylib calloc * How to get a textual representation of an Instrument stack trace? I can take a screenshot but I'm not sure if it is allowed to post images on this list. Thanks, Tino ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: programmitically creating nstextfield
On Wed, Apr 14, 2010 at 9:24 PM, mark wrote: > window=[[NSWindow alloc] initWithContentRect:r styleMask:0 Use the NSBorderlessWindowMask symbolic constant instead of passing 0. > backing:NSBackingStoreRetained defer:NO]; As the documentation says, do not use NSBackingStoreRetained, or in fact anything other than NSBackingStoreBuffered. --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