protocol and properties
Dear list, Suppose I have a formal protocol which defines a method: - (NSArray*)objects; Then I implement a class which implements this protocol. To do that I make a property: @property (nonatomic, readwrite, retain) NSArray * objects; and put the appropriate synthesize statement in the implementation. I get compiler warnings that this class doesn't implement the protocol. It seems it doesn't take the synthesized getter as being an implementation of the -objects method. I also tried explicitly adding the implementation, but the warning remains: - (NSArray*) objects { return objects; } Am I doing something wrong here, or is it not possible to use a property to satisfy a protocol? Best wishes, Martin Martin Hewitson Albert-Einstein-Institut Max-Planck-Institut fuer Gravitationsphysik und Universitaet Hannover Callinstr. 38, 30167 Hannover, Germany Tel: +49-511-762-17121, Fax: +49-511-762-5861 E-Mail: martin.hewit...@aei.mpg.de WWW: http://www.aei.mpg.de/~hewitson ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: protocol and properties
On Sun, Nov 28, 2010 at 2:15 AM, Martin Hewitson martin.hewit...@aei.mpg.de wrote: Suppose I have a formal protocol which defines a method: - (NSArray*)objects; Then I implement a class which implements this protocol. To do that I make a property: @property (nonatomic, readwrite, retain) NSArray * objects; and put the appropriate synthesize statement in the implementation. I get compiler warnings that this class doesn't implement the protocol. It seems it doesn't take the synthesized getter as being an implementation of the -objects method. I also tried explicitly adding the implementation, but the warning remains: - (NSArray*) objects { return objects; } Am I doing something wrong here, or is it not possible to use a property to satisfy a protocol? Works for me: #import Foundation/Foundation.h @protocol Bar - (NSArray*) objects; @end @interface Foo : NSObject Bar { NSArray *objects; } @property (nonatomic, readwrite, retain) NSArray *objects; @end @implementation Foo #if 0 - (NSArray*) objects { return objects; } - (void) setObjects:(NSArray*)o { [o retain]; [objects autorelease]; objects = o; } #else @synthesize objects; #endif @end int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; Foo *f = [[[Foo alloc] init] autorelease]; id Bar b = f; f.objects = [NSArray arrayWithObjects:@one, @two, @three, nil]; NSLog( @objects = %@, [b objects] ); [pool drain]; return 0; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: protocol and properties
It 'works' for me too, I just warnings from Xcode. Anyway, I'll check in case I made a typo or something. Thanks! Martin On 28, Nov, 2010, at 9:50 AM, Stephen J. Butler wrote: On Sun, Nov 28, 2010 at 2:15 AM, Martin Hewitson martin.hewit...@aei.mpg.de wrote: Suppose I have a formal protocol which defines a method: - (NSArray*)objects; Then I implement a class which implements this protocol. To do that I make a property: @property (nonatomic, readwrite, retain) NSArray * objects; and put the appropriate synthesize statement in the implementation. I get compiler warnings that this class doesn't implement the protocol. It seems it doesn't take the synthesized getter as being an implementation of the -objects method. I also tried explicitly adding the implementation, but the warning remains: - (NSArray*) objects { return objects; } Am I doing something wrong here, or is it not possible to use a property to satisfy a protocol? Works for me: #import Foundation/Foundation.h @protocol Bar - (NSArray*) objects; @end @interface Foo : NSObject Bar { NSArray *objects; } @property (nonatomic, readwrite, retain) NSArray *objects; @end @implementation Foo #if 0 - (NSArray*) objects { return objects; } - (void) setObjects:(NSArray*)o { [o retain]; [objects autorelease]; objects = o; } #else @synthesize objects; #endif @end int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; Foo *f = [[[Foo alloc] init] autorelease]; id Bar b = f; f.objects = [NSArray arrayWithObjects:@one, @two, @three, nil]; NSLog( @objects = %@, [b objects] ); [pool drain]; return 0; } Martin Hewitson Albert-Einstein-Institut Max-Planck-Institut fuer Gravitationsphysik und Universitaet Hannover Callinstr. 38, 30167 Hannover, Germany Tel: +49-511-762-17121, Fax: +49-511-762-5861 E-Mail: martin.hewit...@aei.mpg.de WWW: http://www.aei.mpg.de/~hewitson ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: protocol and properties
Then I implement a class which implements this protocol. To do that I make a property: @property (nonatomic, readwrite, retain) NSArray * objects; and put the appropriate synthesize statement in the implementation. I get compiler warnings that this class doesn't implement the protocol. It seems it doesn't take the synthesized getter as being an implementation of the -objects method. I also tried explicitly adding the implementation, but the warning remains: - (NSArray*) objects { return objects; } Am I doing something wrong here, or is it not possible to use a property to satisfy a protocol? Yes, you are doing something wrong. Here you are just using a method that you declared and implemented in a protocol. You need to tell a class where that method is declared and implemented, and you do that like this: @interface ClassIWantToUseSomeProtocolMethodIn : NSObject MyProtocolThatIWantToImplement Bye Mario Kušnjer ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: protocol and properties
On Sun, Nov 28, 2010 at 3:15 AM, Martin Hewitson martin.hewit...@aei.mpg.de wrote: It 'works' for me too, I just warnings from Xcode. Anyway, I'll check in case I made a typo or something. I don't get any warnings. On 28, Nov, 2010, at 9:50 AM, Stephen J. Butler wrote: On Sun, Nov 28, 2010 at 2:15 AM, Martin Hewitson martin.hewit...@aei.mpg.de wrote: Suppose I have a formal protocol which defines a method: - (NSArray*)objects; Then I implement a class which implements this protocol. To do that I make a property: @property (nonatomic, readwrite, retain) NSArray * objects; and put the appropriate synthesize statement in the implementation. I get compiler warnings that this class doesn't implement the protocol. It seems it doesn't take the synthesized getter as being an implementation of the -objects method. I also tried explicitly adding the implementation, but the warning remains: - (NSArray*) objects { return objects; } Am I doing something wrong here, or is it not possible to use a property to satisfy a protocol? Works for me: #import Foundation/Foundation.h @protocol Bar - (NSArray*) objects; @end @interface Foo : NSObject Bar { NSArray *objects; } @property (nonatomic, readwrite, retain) NSArray *objects; @end @implementation Foo #if 0 - (NSArray*) objects { return objects; } - (void) setObjects:(NSArray*)o { [o retain]; [objects autorelease]; objects = o; } #else @synthesize objects; #endif @end int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; Foo *f = [[[Foo alloc] init] autorelease]; id Bar b = f; f.objects = [NSArray arrayWithObjects:@one, @two, @three, nil]; NSLog( @objects = %@, [b objects] ); [pool drain]; return 0; } Martin Hewitson Albert-Einstein-Institut Max-Planck-Institut fuer Gravitationsphysik und Universitaet Hannover Callinstr. 38, 30167 Hannover, Germany Tel: +49-511-762-17121, Fax: +49-511-762-5861 E-Mail: martin.hewit...@aei.mpg.de WWW: http://www.aei.mpg.de/~hewitson ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: protocol and properties
OK, then it seems I didn't do something fundamentally wrong. Probably a stupid mistake somewhere. Thanks again! Martin On 28, Nov, 2010, at 10:26 AM, Stephen J. Butler wrote: On Sun, Nov 28, 2010 at 3:15 AM, Martin Hewitson martin.hewit...@aei.mpg.de wrote: It 'works' for me too, I just warnings from Xcode. Anyway, I'll check in case I made a typo or something. I don't get any warnings. On 28, Nov, 2010, at 9:50 AM, Stephen J. Butler wrote: On Sun, Nov 28, 2010 at 2:15 AM, Martin Hewitson martin.hewit...@aei.mpg.de wrote: Suppose I have a formal protocol which defines a method: - (NSArray*)objects; Then I implement a class which implements this protocol. To do that I make a property: @property (nonatomic, readwrite, retain) NSArray * objects; and put the appropriate synthesize statement in the implementation. I get compiler warnings that this class doesn't implement the protocol. It seems it doesn't take the synthesized getter as being an implementation of the -objects method. I also tried explicitly adding the implementation, but the warning remains: - (NSArray*) objects { return objects; } Am I doing something wrong here, or is it not possible to use a property to satisfy a protocol? Works for me: #import Foundation/Foundation.h @protocol Bar - (NSArray*) objects; @end @interface Foo : NSObject Bar { NSArray *objects; } @property (nonatomic, readwrite, retain) NSArray *objects; @end @implementation Foo #if 0 - (NSArray*) objects { return objects; } - (void) setObjects:(NSArray*)o { [o retain]; [objects autorelease]; objects = o; } #else @synthesize objects; #endif @end int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; Foo *f = [[[Foo alloc] init] autorelease]; id Bar b = f; f.objects = [NSArray arrayWithObjects:@one, @two, @three, nil]; NSLog( @objects = %@, [b objects] ); [pool drain]; return 0; } Martin Hewitson Albert-Einstein-Institut Max-Planck-Institut fuer Gravitationsphysik und Universitaet Hannover Callinstr. 38, 30167 Hannover, Germany Tel: +49-511-762-17121, Fax: +49-511-762-5861 E-Mail: martin.hewit...@aei.mpg.de WWW: http://www.aei.mpg.de/~hewitson Martin Hewitson Albert-Einstein-Institut Max-Planck-Institut fuer Gravitationsphysik und Universitaet Hannover Callinstr. 38, 30167 Hannover, Germany Tel: +49-511-762-17121, Fax: +49-511-762-5861 E-Mail: martin.hewit...@aei.mpg.de WWW: http://www.aei.mpg.de/~hewitson ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: protocol and properties
On 28, Nov, 2010, at 10:22 AM, Mario Kušnjer wrote: Then I implement a class which implements this protocol. To do that I make a property: @property (nonatomic, readwrite, retain) NSArray * objects; and put the appropriate synthesize statement in the implementation. I get compiler warnings that this class doesn't implement the protocol. It seems it doesn't take the synthesized getter as being an implementation of the -objects method. I also tried explicitly adding the implementation, but the warning remains: - (NSArray*) objects { return objects; } Am I doing something wrong here, or is it not possible to use a property to satisfy a protocol? Yes, you are doing something wrong. Here you are just using a method that you declared and implemented in a protocol. You need to tell a class where that method is declared and implemented, and you do that like this: @interface ClassIWantToUseSomeProtocolMethodIn : NSObject MyProtocolThatIWantToImplement Sorry, I am doing that, I just didn't write it in the mail. That's why I get the warnings 'Class doesn't fully implement protocol'. Cheers, Martin Bye Mario Kušnjer Martin Hewitson Albert-Einstein-Institut Max-Planck-Institut fuer Gravitationsphysik und Universitaet Hannover Callinstr. 38, 30167 Hannover, Germany Tel: +49-511-762-17121, Fax: +49-511-762-5861 E-Mail: martin.hewit...@aei.mpg.de WWW: http://www.aei.mpg.de/~hewitson ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 encrypt a String to a SHA-1 Encrypted in iPhone
Hi, Your implementation should work, but I have a few suggestions for you. * Unless you need HMAC specifically, the function you are using is in CommonCrypto/CommonDigest.h. * In general, I think Apple discourages relying on the output of the description, although I see that the documentation for NSData states that description will produce a string in property list format, so it is unlikely to change. For your needs, there is a better way anyway. * While there is nothing wrong with using a class method, consider adding a category method to the class. * You can verify your results with openssl on the command line. In Terminal: $ echo -n Some text to hash | openssl dgst -sha1 or $ openssl dgst -sha1 /path/to/file/to/hash * NSString has a method that returns an NSData, so you don't have to create an intermediate C string. * SHA1 and MD5 are hashes, not encryption. Strictly speaking it is incorrect to refer to them as encryption. Here is an alternate implementation with an example usage: #import Foundation/Foundation.h #include CommonCrypto/CommonDigest.h @interface NSData (NSDataDigestCategory) - (NSString *)sha1; @end @implementation NSData (NSDataDigestCategory) - (NSString *)sha1 { uint8_t digest[CC_SHA1_DIGEST_LENGTH]; CC_SHA1([self bytes], [self length], digest); // use an uppercase X to get an uppercase hash NSString *hash = [NSString stringWithFormat:@%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x, digest[0], digest[1], digest[2], digest[3], digest[4], digest[5], digest[6], digest[7], digest[8], digest[9], digest[10], digest[11], digest[12], digest[13], digest[14], digest[15], digest[16], digest[17], digest[18], digest[19], digest[20]]; // or, if you prefer: NSMutableString *hash2 = [NSMutableString stringWithCapacity:40]; for (int i = 0; i CC_SHA1_DIGEST_LENGTH; i++) [hash2 appendFormat:@%02x, digest[i]]; return hash; // or hash2 } @end @interface NSString (NSStringDigestCategory) - (NSString *)sha1; @end @implementation NSString (NSStringDigestCategory) - (NSString *)sha1 { NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding]; return [data sha1]; } @end int main(int argc, char *argv[]) { NSAutoreleasePool *pool = [NSAutoreleasePool new]; NSLog(@SHA1: %@, [@Some text to hash sha1]); [pool drain]; return 0; } On Nov 27, 2010, at 3:39 AM, Tharindu Madushanka wrote: Hi, It was just I need to add CommonCrypto/CommonHMAC.h header. But above code didn't work. But following encoded to SHA-1 correctly.. I would like to know whether it encodes right ? or Not ? CommonCrypto/CommonHMAC.h +(NSString *)stringToSha1:(NSString *)hashkey{ // Using UTF8Encoding const char *s = [hashkey cStringUsingEncoding:NSUTF8StringEncoding]; NSData *keyData = [NSData dataWithBytes:s length:strlen(s)]; // This is the destination uint8_t digest[CC_SHA1_DIGEST_LENGTH] = {0}; // This one function does an unkeyed SHA1 hash of your hash data CC_SHA1(keyData.bytes, keyData.length, digest); // Now convert to NSData structure to make it usable again NSData *out = [NSData dataWithBytes:digest length:CC_SHA1_DIGEST_LENGTH]; // description converts to hex but puts around it and spaces every 4 bytes NSString *hash = [out description]; hash = [hash stringByReplacingOccurrencesOfString:@ withString:@]; hash = [hash stringByReplacingOccurrencesOfString:@ withString:@]; hash = [hash stringByReplacingOccurrencesOfString:@ withString:@]; // hash is now a string with just the 40char hash value in it return hash; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/aaron.burghardt%40gmail.com This email sent to aaron.burgha...@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
Problem with custom NSTextFieldCell
I am trying to use a custom NSTextFieldCell (MyCell) in my NSTableView. The custom MyCell displays two text values instead of one. When ever the row is clicked or double clicked the dealloc method of the NSTextFieldCell is called. Why is the NSTextFieldCell being dealloced when the entry is selected in the table? How do I intercept double clicks to MyCell and make each part editable? Thanks Hrishi ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSTask with unzip
Yes, this looks good. I like your category on NSFileHandle (not a subclass!); it's cleaner than the code at the link I sent you, since it doesn't just eat the error, and it's better as a category. Four things I would mention: 1) Checking that the pipe could be created and actually has a file handle for reading would be a good idea; [NSPipe pipe] is documented as being allowed to return nil 2) Checking -terminationStatus is a good idea once the task completes (after you're done pulling data out, you can then safely call -waitUntilExit on the task to be certain it has completed before calling -terminationStatus, AFAIK) 3) You only use a pipe for standard out, not for standard in, but it's worth noting that a pipe for standard in needs to receive a -closeFile call or the file descriptor for that pipe doesn't get deleted correctly. As a reminder to myself about this issue, I just send -closeFile to all of the pipes I'm using with a task, so that I don't forget to do it. But your code is correct; I mention this just in case someone reading the archives adapts this code to a task that requires a standard in pipe. 4) -launch can raise, so it is good to think about that; but as long as you're comfortable with your method raising, your code seems fine to me. Good stuff! If anybody on the list knows whether the bug that the -availableDataOrError: hack circumvents has been fixed, and in what OS X release, I'd love to know that so I know whether it's safe to delete that rather unpleasant hack from my code. Ben Haller McGill University On 2010-11-27, at 3:43 PM, Leonardo wrote: Ben, thank you so much! I have successfully done it. I post the code here for anyone to use it. I love this list. - (NSData*)UnzipFile:(NSString*)sourcePath extractFileName:(NSString*)extractFileName { NSTask*unzip = [[[NSTask alloc] init] autorelease]; NSPipe*aPipe = [NSPipe pipe]; [unzip setStandardOutput:aPipe]; [unzip setLaunchPath:@/usr/bin/unzip]; [unzip setArguments:[NSArray arrayWithObjects:@-p, sourcePath, extractFileName, nil]]; [unzip launch]; NSMutableData*dataOut = [NSMutableData data]; NSData*dataIn = nil; NSException*error = nil; while((dataIn = [[aPipe fileHandleForReading] availableDataOrError:error]) [dataIn length] error == nil){ [dataOut appendData:dataIn]; } if([dataOut length] error == nil){ return dataOut; } return nil; } // Then I subclassed NSFileHandler this way @implementation NSFileHandle (MyOwnAdditions) - (NSData*)availableDataOrError:(NSException**)returnError { for(;;){ @try{ return [self availableData]; }...@catch (NSException *e) { if ([[e name] isEqualToString:NSFileHandleOperationException]) { if ([[e reason] isEqualToString:@*** -[NSConcreteFileHandle availableData]: Interrupted system call]) { continue; } if (returnError) *returnError = e; return nil; } @throw; } } } @end Da: Ben Haller bhcocoa...@sticksoftware.com Data: Sat, 27 Nov 2010 12:12:39 -0500 A: Dave DeLong davedel...@me.com Cc: gMail.com mac.iphone@gmail.com, Cocoa List cocoa-dev@lists.apple.com Oggetto: Re: NSTask with unzip Here's a post that I found useful: http://dev.notoptimal.net/2007/04/nstasks-nspipes-and-deadlocks-when.html Dave, not sure what you mean here. NSPipe uses NSFileHandle. Does using an NSFileHandle directly change things somehow? If so, why? I think this is an avenue I haven't explored; once I (finally) figured out the right magic incantations to get things to work reliably with NSPipe, I now recycle that code everywhere I need an NSTask :-. Ben Haller McGill University On 2010-11-27, at 11:48 AM, Dave DeLong wrote: The way I get around this is to use an NSFileHandle for standard out instead of an NSPipe. It's a bit less efficient, but slightly more convenient. Dave Sent from my iPhone On Nov 27, 2010, at 7:59 AM, Ben Haller bhcocoa...@sticksoftware.com wrote: On 2010-11-26, at 7:33 AM, gMail.com wrote: Hi, I can properly unzip a zip file launching a NSTask with /usr/bin/unzip The task saves the unzipped file to the disk, then a I read the unzipped file in a NSData. Well. My question is: Can I do the same job without saving the unzipped file to the disk? I have tried to set the standard output to a pipe - which works well with other tasks - but here it doesn't work. The task never exits. Here's the wrong code: NSTask *unzip = [[[NSTask alloc] init] autorelease]; [unzip setLaunchPath:@/usr/bin/unzip]; [unzip setArguments:[NSArray arrayWithObjects:@-p, zipfile, @filetounzip, nil]]; NSPipe *aPipe = [NSPipe pipe]; [unzip setStandardOutput:aPipe]; [unzip launch]; [unzip waitUntilExit];
Re: Icon Designer?
On 27 nov 2010, at 23.22, Andrew McLaughlin wrote: Thanks. But I need help with the aesthetic perspective, not on the file building. Something like this perhaps: http://iconfactory.com/design ...but we're now off-topic for this mailing list. j o a r ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
view doesn't respond to very first mouse event
Hi all! I have an AudioUnit plugin with a Cocoa View. The view itself is a subclass of NSControl. It works well, however, it doesn't respond to the very first mouse down or mouse dragged event. This very first click or drag only makes the view active, only starting from the second click or drag that it starts to respond to these events. How can I fix this? Would really appreciate any advise. Thanks and best wishes, Artemiy. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Codesign failure
Hi, I did redownload and reinstall the certificates. I get now: /Volumes/Spare/GraphicConverter.app: CSSMERR_TP_NOT_TRUSTED Not much better. Thorsten Did you just download them in the last day or has it been a week or two? You do have Xcode 3.2.5 right? For the first week or so after 3.2.5 was released the certificates downloaded from the member site were bad. Apple made some changes and that cleared up I think most of the issues (including mine). But there were a number of posts in the Developer forums about this issue. Even if you did just download them I would try to delete the certificates (from your Keychain too) and then redo them completely. If you still have the same issue I'm not sure what else could be the cause except maybe some people are still experiencing this and it's still being discussed in the Developer forums... HTH rc ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: view doesn't respond to very first mouse event
Fixed by adding this to @implementation: - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent { return YES; } :-) On 28 Nov 2010, at 18:51, Artemiy Pavlov wrote: Hi all! I have an AudioUnit plugin with a Cocoa View. The view itself is a subclass of NSControl. It works well, however, it doesn't respond to the very first mouse down or mouse dragged event. This very first click or drag only makes the view active, only starting from the second click or drag that it starts to respond to these events. How can I fix this? Would really appreciate any advise. Thanks and best wishes, Artemiy. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/artemiy.pavlov%40ukrpost.ua This email sent to artemiy.pav...@ukrpost.ua ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: OutlineView with big text editor
Patrick, I tried that method but it never gets invoked. I added it to my NSTextFieldCell subclass. I double click on the outline row, edit the text, press return, the text changes, the cell closes, but the method editWithFrame never gets called. I even tried to add [self setWantsNotificationForMarkedText:YES]; in the init method, but nothing changes. Instead the method setUpFieldEditorAttributes: gets called, but here I can just change the background color of the cell, not the frame nor the text color... What do I miss? --Leonardo Da: Patrick Mau p...@me.com Data: Sun, 28 Nov 2010 02:35:05 +0100 A: gMail.com mac.iphone@gmail.com Cc: cocoa-dev@lists.apple.com Oggetto: Re: OutlineView with big text editor On 27.11.2010, at 15:43, gMail.com http://gMail.com wrote: Hi, I have set a custom cell showing icon + text on my outlineView column. It works well, but whenever I double click on the row to edit the text, I get a text field editor bigger than the cell itself and covering the left icon. How can I make this text field editor fit the cell bounds and not covering the left icon? Hi Leo Your NSCell implementation should implement something like the following. In 'editWithFrame:...' you have to account for your image size and adjust the cell frame before calling super. (Copied from a custom cell code, but typed in mail to give you the idea) - (void)editWithFrame:(NSRect)r inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)theEvent { // Adjust the cell frame to not cover the image r.origin.x += imageWidth; r.size.width -= imageWidth; [super editWithFrame:r inView:controlView editor:textObj delegate:anObject event:theEvent]; } Patrick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
hidden file
Hi everyone, how to check whether a file is hidden in Finder? There seems file manager has no any methods to change file`s visibility like lchflags(). -- best regards Ariel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: hidden file
On Nov 28, 2010, at 3:09 PM, Ariel Feinerman wrote: Hi everyone, how to check whether a file is hidden in Finder? There seems file manager has no any methods to change file`s visibility like lchflags(). There are three different things that can cause a file to be hidden in the Finder: 1. If it has a . at the beginning of its name 2. If its hidden bit is set (you can check for this using the Carbon file manager) 3. If its name comes up inside the .hidden file in the same folder (if such a file exists) And yes, I have a bug open on this asking for a way to do this using NSFileManager. 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: hidden file
On Sun, Nov 28, 2010 at 4:21 PM, Nick Zitzmann n...@chronosnet.com wrote: 1. If it has a . at the beginning of its name 2. If its hidden bit is set (you can check for this using the Carbon file manager) 3. If its name comes up inside the .hidden file in the same folder (if such a file exists) LSCopyItemInfoForURL() covers at least the first two cases. Don't know about the third. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: OutlineView with big text editor [SOLVED]
I have found a solution. I have overrided the method selectWithFrame:(NSRect)aRect inView: in my NSTextCell subclass. Here I modify the frame of the field editor It works. Thanks anyway. -- Leonardo Da: Patrick Mau p...@me.com Data: Sun, 28 Nov 2010 02:35:05 +0100 A: gMail.com mac.iphone@gmail.com Cc: cocoa-dev@lists.apple.com Oggetto: Re: OutlineView with big text editor On 27.11.2010, at 15:43, gMail.com http://gMail.com wrote: Hi, I have set a custom cell showing icon + text on my outlineView column. It works well, but whenever I double click on the row to edit the text, I get a text field editor bigger than the cell itself and covering the left icon. How can I make this text field editor fit the cell bounds and not covering the left icon? Hi Leo Your NSCell implementation should implement something like the following. In 'editWithFrame:...' you have to account for your image size and adjust the cell frame before calling super. (Copied from a custom cell code, but typed in mail to give you the idea) - (void)editWithFrame:(NSRect)r inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)theEvent { // Adjust the cell frame to not cover the image r.origin.x += imageWidth; r.size.width -= imageWidth; [super editWithFrame:r inView:controlView editor:textObj delegate:anObject event:theEvent]; } Patrick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSTask with unzip
Great! Thanks for the advises. Now I have to zip and unzip a NSData (not a zip file) to a NSData. In other words, I have to zip and unzip data to data, without using any file. Some idea? -- Leonardo Da: Ben Haller bhcocoa...@sticksoftware.com Data: Sun, 28 Nov 2010 08:52:33 -0500 A: Leonardo mac.iphone@gmail.com, Cocoa List cocoa-dev@lists.apple.com Oggetto: Re: NSTask with unzip Yes, this looks good. I like your category on NSFileHandle (not a subclass!); it's cleaner than the code at the link I sent you, since it doesn't just eat the error, and it's better as a category. Four things I would mention: 1) Checking that the pipe could be created and actually has a file handle for reading would be a good idea; [NSPipe pipe] is documented as being allowed to return nil 2) Checking -terminationStatus is a good idea once the task completes (after you're done pulling data out, you can then safely call -waitUntilExit on the task to be certain it has completed before calling -terminationStatus, AFAIK) 3) You only use a pipe for standard out, not for standard in, but it's worth noting that a pipe for standard in needs to receive a -closeFile call or the file descriptor for that pipe doesn't get deleted correctly. As a reminder to myself about this issue, I just send -closeFile to all of the pipes I'm using with a task, so that I don't forget to do it. But your code is correct; I mention this just in case someone reading the archives adapts this code to a task that requires a standard in pipe. 4) -launch can raise, so it is good to think about that; but as long as you're comfortable with your method raising, your code seems fine to me. Good stuff! If anybody on the list knows whether the bug that the -availableDataOrError: hack circumvents has been fixed, and in what OS X release, I'd love to know that so I know whether it's safe to delete that rather unpleasant hack from my code. Ben Haller McGill University On 2010-11-27, at 3:43 PM, Leonardo wrote: Ben, thank you so much! I have successfully done it. I post the code here for anyone to use it. I love this list. - (NSData*)UnzipFile:(NSString*)sourcePath extractFileName:(NSString*)extractFileName { NSTask*unzip = [[[NSTask alloc] init] autorelease]; NSPipe*aPipe = [NSPipe pipe]; [unzip setStandardOutput:aPipe]; [unzip setLaunchPath:@/usr/bin/unzip]; [unzip setArguments:[NSArray arrayWithObjects:@-p, sourcePath, extractFileName, nil]]; [unzip launch]; NSMutableData*dataOut = [NSMutableData data]; NSData*dataIn = nil; NSException*error = nil; while((dataIn = [[aPipe fileHandleForReading] availableDataOrError:error]) [dataIn length] error == nil){ [dataOut appendData:dataIn]; } if([dataOut length] error == nil){ return dataOut; } return nil; } // Then I subclassed NSFileHandler this way @implementation NSFileHandle (MyOwnAdditions) - (NSData*)availableDataOrError:(NSException**)returnError { for(;;){ @try{ return [self availableData]; }...@catch (NSException *e) { if ([[e name] isEqualToString:NSFileHandleOperationException]) { if ([[e reason] isEqualToString:@*** -[NSConcreteFileHandle availableData]: Interrupted system call]) { continue; } if (returnError) *returnError = e; return nil; } @throw; } } } @end Da: Ben Haller bhcocoa...@sticksoftware.com Data: Sat, 27 Nov 2010 12:12:39 -0500 A: Dave DeLong davedel...@me.com Cc: gMail.com mac.iphone@gmail.com, Cocoa List cocoa-dev@lists.apple.com Oggetto: Re: NSTask with unzip Here's a post that I found useful: http://dev.notoptimal.net/2007/04/nstasks-nspipes-and-deadlocks-when.html Dave, not sure what you mean here. NSPipe uses NSFileHandle. Does using an NSFileHandle directly change things somehow? If so, why? I think this is an avenue I haven't explored; once I (finally) figured out the right magic incantations to get things to work reliably with NSPipe, I now recycle that code everywhere I need an NSTask :-. Ben Haller McGill University On 2010-11-27, at 11:48 AM, Dave DeLong wrote: The way I get around this is to use an NSFileHandle for standard out instead of an NSPipe. It's a bit less efficient, but slightly more convenient. Dave Sent from my iPhone On Nov 27, 2010, at 7:59 AM, Ben Haller bhcocoa...@sticksoftware.com wrote: On 2010-11-26, at 7:33 AM, gMail.com wrote: Hi, I can properly unzip a zip file launching a NSTask with /usr/bin/unzip The task saves the unzipped file to the disk, then a I read the unzipped file in a NSData. Well. My question is: Can I do the same job without saving the unzipped file to the disk? I have tried to set the standard
Re: hidden file
On Nov 28, 2010, at 4:21 PM, Nick Zitzmann wrote: On Nov 28, 2010, at 3:09 PM, Ariel Feinerman wrote: Hi everyone, how to check whether a file is hidden in Finder? There seems file manager has no any methods to change file`s visibility like lchflags(). There are three different things that can cause a file to be hidden in the Finder: 1. If it has a . at the beginning of its name 2. If its hidden bit is set (you can check for this using the Carbon file manager) 3. If its name comes up inside the .hidden file in the same folder (if such a file exists) And yes, I have a bug open on this asking for a way to do this using NSFileManager. As of 10.6, the recommendation is to use NSURL for referencing files and accessing their metadata. In particular, see -getResourceValue:forKey:error:/-setResourceValue:forKey:error: and NSURLIsHiddenKey. 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: NSTask with unzip
On Nov 28, 2010, at 4:51 PM, Leonardo wrote: Great! Thanks for the advises. Now I have to zip and unzip a NSData (not a zip file) to a NSData. In other words, I have to zip and unzip data to data, without using any file. Some idea? -- Leonardo A quick google search turns up several Cocoa zip frameworks out there that will avoid having to use NSTask, etc... all together. While the zip file format is ugly, it is documented and you can always write your own to walk through a zip file to find the objects you want and use the standard zlib routines to do the compression/decompression. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSXMLParser chokes on DTD declaration
If I use NSXMLParser (on 10.6.5) to parse xml data that looks like this: ?xml version=1.0 encoding=UTF-8 standalone=no ? !DOCTYPE docData SYSTEM docData.dtd docData [elements omitted] /docData and if I have sent the parser a setShouldResolveExternalEntities:YES message, I would expect the parser delegate message parser:resolveExternalEntityName:systemID: to fire, as described in Event-Driven XML Programming Guide. Instead, parser:parseErrorOccurred: gives an error with this description: Error Domain=NSXMLParserErrorDomain Code=1549 The operation couldn’t be completed. (NSXMLParserErrorDomain error 1549.) Where did I go wrong? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 approach to write such an app?
Hi all, No clue for this? Probably I should rephrase my question as below: Suppose I have an forum powered by Discuz. I want to write an iPhone application which can access that forum, any forum operation like browsing, reply, change profile, make it favourite post etc can be done in that iPhone application as well. I just wonder how to approach that, say what documents I should read first, what knowledge or technology I should master to do it? My idea is to start with reading CFNetwork programming guide and stream programming guide for cocoa. I also wonder if JSON and ASIHTTPRequest( http://allseeing-i.com/ASIHTTPRequest/How-to-use) could help. Can you guys point me a right direction to approach writing this app? Any advice is appreciated! On Sun, Nov 28, 2010 at 2:57 PM, ico jche...@gmail.com wrote: Hi All, Suppose I have an forum powered by Discuz. I want to write an iPhone application which is like a portal can access that forum, any forum operation like browsing, reply, change profile, make it favourite post etc can be done in that iPhone application as well. I just wonder how to approach that, say what documents I should read first, what knowledge or technology I should master to do it? My idea is to start with reading CFNetwork programming guide and stream programming guide for cocoa. Any advice is appreciated! -- == Life isn't about finding yourself. Life is about creating yourself. -- == Life isn't about finding yourself. Life is about creating yourself. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 approach to write such an app?
Maybe you got no response because every iPhone comes with an app that can do that, safari. From: ico jche...@gmail.com Date: Sun, 28 Nov 2010 22:01:09 -0500 To: cocoa-dev@lists.apple.com Subject: Re: How to approach to write such an app? Hi all, No clue for this? Probably I should rephrase my question as below: Suppose I have an forum powered by Discuz. I want to write an iPhone application which can access that forum, any forum operation like browsing, reply, change profile, make it favourite post etc can be done in that iPhone application as well. I just wonder how to approach that, say what documents I should read first, what knowledge or technology I should master to do it? My idea is to start with reading CFNetwork programming guide and stream programming guide for cocoa. I also wonder if JSON and ASIHTTPRequest( http://allseeing-i.com/ASIHTTPRequest/How-to-use) could help. Can you guys point me a right direction to approach writing this app? Any advice is appreciated! On Sun, Nov 28, 2010 at 2:57 PM, ico jche...@gmail.com wrote: Hi All, Suppose I have an forum powered by Discuz. I want to write an iPhone application which is like a portal can access that forum, any forum operation like browsing, reply, change profile, make it favourite post etc can be done in that iPhone application as well. I just wonder how to approach that, say what documents I should read first, what knowledge or technology I should master to do it? My idea is to start with reading CFNetwork programming guide and stream programming guide for cocoa. Any advice is appreciated! -- == Life isn't about finding yourself. Life is about creating yourself. -- == Life isn't about finding yourself. Life is about creating yourself. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/chris%40clwill.com This email sent to ch...@clwill.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: NSTask with unzip
On Sun, Nov 28, 2010 at 3:12 PM, glenn andreas gandr...@mac.com wrote: A quick google search turns up several Cocoa zip frameworks out there that will avoid having to use NSTask, etc... all together. While the zip file format is ugly, it is documented and you can always write your own to walk through a zip file to find the objects you want and use the standard zlib routines to do the compression/decompression. Shameless plug for OmniUnzip, part of the Omni Frameworks: https://github.com/omnigroup/OmniGroup/tree/master/Frameworks/OmniUnzip/ --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: How to approach to write such an app?
You really don't need so much. These ideas are not totally wrong, they're possible, but a bit unnecessary. (reinventing wheels) You may want to consider starting with basic iOS app development. Also consider that many web apps (blogs, forums, etc...) have APIs made of SOAP or REST calls. URLs also pass data back and forth. You should review basics of HTPP and web app development and then look at the cocoa and cocoa touch classes related to URL handling, cookies, etc... You can make an app much like the facebook app and only store the user login data and then you have a custom local UI with buttons that interact with the site, then a view that renders content returned from the site. Not hard, just a bit of reading. Learn the basics first. Cocoa is rich, and big, and most of what you need is already there. However, you cannot start Cocoa without first learning from the ground up. Just hacking junk together will result in a crappy app. On Nov 29, 2010, at 12:01 PM, ico wrote: Hi all, No clue for this? Probably I should rephrase my question as below: Suppose I have an forum powered by Discuz. I want to write an iPhone application which can access that forum, any forum operation like browsing, reply, change profile, make it favourite post etc can be done in that iPhone application as well. I just wonder how to approach that, say what documents I should read first, what knowledge or technology I should master to do it? My idea is to start with reading CFNetwork programming guide and stream programming guide for cocoa. I also wonder if JSON and ASIHTTPRequest( http://allseeing-i.com/ASIHTTPRequest/How-to-use) could help. Can you guys point me a right direction to approach writing this app? Any advice is appreciated! On Sun, Nov 28, 2010 at 2:57 PM, ico jche...@gmail.com wrote: Hi All, Suppose I have an forum powered by Discuz. I want to write an iPhone application which is like a portal can access that forum, any forum operation like browsing, reply, change profile, make it favourite post etc can be done in that iPhone application as well. I just wonder how to approach that, say what documents I should read first, what knowledge or technology I should master to do it? My idea is to start with reading CFNetwork programming guide and stream programming guide for cocoa. Any advice is appreciated! -- == Life isn't about finding yourself. Life is about creating yourself. -- == Life isn't about finding yourself. Life is about creating yourself. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/jjoyce%40apple.com This email sent to jjo...@apple.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTask with unzip
On Nov 28, 2010, at 3:51 PM, Leonardo wrote: Great! Thanks for the advises. Now I have to zip and unzip a NSData (not a zip file) to a NSData. In other words, I have to zip and unzip data to data, without using any file. Some idea? Use zlib directly. It's not too hard to compress buffer to buffer. -- Scott Ribe scott_r...@elevated-dev.com http://www.elevated-dev.com/ (303) 722-0567 voice ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to approach to write such an app?
Hi Jeff, I am not going to store threads and messages into the iPhone. The app merely get data from the forum(web server). And store the data into the forum(web server) as well. I know it uses MySQL database. So if the user post a new thread to the forum through my App, I should store those data into the web server as well just like you do through a browser on PC. The only data I plan to store in the iPhone is the user login data. So that they don't need to login every time when launching the app. Of course I would provide an option to them for not storing login data at all for privacy reason. btw, how can I encrypt those login data such as login name and password in the iPhone? On Mon, Nov 29, 2010 at 11:44 AM, Jeff Kelley slauncha...@gmail.com wrote: The data format isn’t really the big deal here. Instead, you should think about the internal structure of your app; how are you going to store users, threads, individual messages, different forums, etc.? Core Data is an option, which gets you persistence for free. Once you get that figured out, getting the information from the server to the application is a matter of getting the data from one format to another. -Jeff On Nov 28, 2010, at 10:33 PM, ico wrote: Thanks for your reply. I actually just found out that Discuz is like a brand. I thought it was commonly used world wide. Actually Discuz is just a forum written in PHP. Sure I should communicate with that team to see what they can provide.(data format, functions etc). Anyway, what if this forum is simply like many PHP forum out there, what is the best approach to communicate with this forum through my iPhone app? Is JSON the best way to do suppose it supports JSON and XML formated pages. Or it only supports to provide HTML stuff, should I work on the server side to make it supports providing JSON or XML formated pages? All in one is that I want to know the best way to approach that no matter what data format it can provide. Assume that I am able to make it to support that data format even though it originally does not. On Mon, Nov 29, 2010 at 11:09 AM, Jeff Kelley slauncha...@gmail.comwrote: Hello, You may have not gotten a response yet because this list focuses on Cocoa development, but your question is really more of a Discuz question. How you approach writing an application will depend on what kinds of data you can get from the Discuz installation, whether it gives you JSON- or XML-formatted pages, or if you’ll have to scrape the HTML to get it to work. I’d recommend reading the Discuz documentation or asking on its discussion forum, if it has one. Jeffrey R. Kelley slauncha...@gmail.com On Sun, Nov 28, 2010 at 10:01 PM, ico jche...@gmail.com wrote: Hi all, No clue for this? Probably I should rephrase my question as below: Suppose I have an forum powered by Discuz. I want to write an iPhone application which can access that forum, any forum operation like browsing, reply, change profile, make it favourite post etc can be done in that iPhone application as well. I just wonder how to approach that, say what documents I should read first, what knowledge or technology I should master to do it? My idea is to start with reading CFNetwork programming guide and stream programming guide for cocoa. I also wonder if JSON and ASIHTTPRequest( http://allseeing-i.com/ASIHTTPRequest/How-to-use) could help. Can you guys point me a right direction to approach writing this app? Any advice is appreciated! On Sun, Nov 28, 2010 at 2:57 PM, ico jche...@gmail.com wrote: Hi All, Suppose I have an forum powered by Discuz. I want to write an iPhone application which is like a portal can access that forum, any forum operation like browsing, reply, change profile, make it favourite post etc can be done in that iPhone application as well. I just wonder how to approach that, say what documents I should read first, what knowledge or technology I should master to do it? My idea is to start with reading CFNetwork programming guide and stream programming guide for cocoa. Any advice is appreciated! -- == Life isn't about finding yourself. Life is about creating yourself. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 encrypt a String to a SHA-1 Encrypted in iPhone
@implementation NSData (NSDataDigestCategory) - (NSString *)sha1 { uint8_t digest[CC_SHA1_DIGEST_LENGTH]; CC_SHA1([self bytes], [self length], digest); // use an uppercase X to get an uppercase hash NSString *hash = [NSString stringWithFormat:@%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x, digest[0], digest[1], digest[2], digest[3], digest[4], digest[5], digest[6], digest[7], digest[8], digest[9], digest[10], digest[11], digest[12], digest[13], digest[14], digest[15], digest[16], digest[17], digest[18], digest[19], digest[20]]; // or, if you prefer: NSMutableString *hash2 = [NSMutableString stringWithCapacity:40]; for (int i = 0; i CC_SHA1_DIGEST_LENGTH; i++) [hash2 appendFormat:@%02x, digest[i]]; return hash; // or hash2 } @end There's no such thing as an 'uppercase hash'. Technically, this doesn't return an SHA-1 hash, which would be 20 bytes of binary data, this returns a Base16 encoded SHA-1 hash, which is 40 characters in the range [0..F] (with values in the range [0b1010..0b] mapping to a value in the domain of either [A..F] or [a..f] which is where the 'case' comes into it). This method should either return an NSData object of the digest bytes, and the category should include an additional method to return a base-converted NSString object representing the receiver i.e. @interface NSData (MyNSDataAdditions) - (NSData *)SHA1; - (NSString *)base16String; @end or amend the current method name to imply that the encoding is base16 i.e. @interface NSData (MyNSDataAdditions) - (NSString *)sha1WithBase16Encoding; @end Cheers, Keith ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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