problem with applying md5 to data

2011-06-29 Thread Wilker
Hi guys, I need to generate a hash from a file, the hash algorithm is here: http://thesubdb.com/api/ I'm trying to implement it on Objective-C but I'm having really trouble on it... This is my current implementation: // // SMSubdbSource.m // Subtitle Master // // Created by Wilker Lúcio da S

NSDocument new file logic

2011-06-29 Thread Martin Hewitson
Dear list, I have an NSPersistentDocument subclass which encapsulates a project for the user. When the user creates a new project, they specify a name and a location on disk. I then want to create a new instance of my NSDocument subclass as if it was saved exactly where the user wants it to be.

Re: problem with applying md5 to data

2011-06-29 Thread Quincey Morris
On Jun 29, 2011, at 00:02, Wilker wrote: > I'm trying to implement it on Objective-C but I'm having really trouble on > it... There are many things wrong with your implementation. > +(NSString *)generateHashFromPath:(NSString *)path { >const NSUInteger CHUNK_SIZE = 65536; > >NSFileHandl

Re: problem with applying md5 to data

2011-06-29 Thread Wilker
Thanks for the answer Quincey, I did resolved just before you post here :) Used this (now in separated files): +(NSString *)md5HexDigestFromChar:(const void *)str withLength:(CC_LONG)lenght { unsigned char result[CC_MD5_DIGEST_LENGTH]; CC_MD5(str, lenght, result); NSMutableString *

Re: NSDocument new file logic

2011-06-29 Thread Quincey Morris
On Jun 28, 2011, at 23:58, Martin Hewitson wrote: > In the past I achieved this in a somewhat unsatisfactory way by just calling > newDocument: then saveDocument: and getting the user to immediately save the > document before the app does the rest of the setup steps. Using the action methods (n

Re: problem with applying md5 to data

2011-06-29 Thread Quincey Morris
On Jun 29, 2011, at 00:27, Quincey Morris wrote: >> [fileData appendData:[file readDataOfLength:CHUNK_SIZE]]; >> [file seekToFileOffset:MAX(0, fileSize - CHUNK_SIZE)]; >> [fileData appendData:[file readDataOfLength:CHUNK_SIZE]]; >> >> [file closeFile]; > > This is not the worst way to re

Re: NSDocument new file logic

2011-06-29 Thread Martin Hewitson
Wonderful! Thanks very much. I will give this a try. Writing out the core data store was the bit I was missing. Martin On Jun 29, 2011, at 9:54 AM, Quincey Morris wrote: > On Jun 28, 2011, at 23:58, Martin Hewitson wrote: > >> In the past I achieved this in a somewhat unsatisfactory way by ju

Properties, Attributes and Retain+Autorelease

2011-06-29 Thread Markus Hanauska
Unfortunately the documentation on properties is really inadequate since Apple fails to provide "pseudo-code" for every possible attribute combination. E.g. the nonatomic attribute has a couple of dangerous side effects that seem to be unknown even to developers using properties for years. The d

Re: Properties, Attributes and Retain+Autorelease

2011-06-29 Thread Fritz Anderson
On 29 Jun 2011, at 5:53 AM, Markus Hanauska wrote: > The code above already reveals a huge problem: When I read the terms "atomic" > and "nonatomic", I certainly expect one to use a lock (or at least atomic > operations of some kind) and the other one not. This is no big surprise. What > is a b

Re: dispatch_async Performance Issues

2011-06-29 Thread Andreas Grosam
Hi Jonathan, I'm happy that your guesses exactly match the results of my investigations. :) Actually, the compiler (LLVM here) is doing an amazing job when optimizing. Although I'm happy with this, it makes such tests a pain, since often enough the compiler simply strips the code away what I wa

Fuzzy string matching

2011-06-29 Thread Eric E. Dolecki
Hey all, I have an application (iOS) that is doing speech to text. The resulting string I'd like to fuzzy match against the user's onboard music library, and play a song, album, genre, etc. as appropriate. I am looking for a really good fuzzy string matching engine. I found this: http://www.locayt

who is currently the first responder? (iOS)

2011-06-29 Thread Roland King
Is there a way to find out what UIResponder is the current first responder, the one with the keyboard up? I have a number of editable fields, each on a cell of a table view which is in a UIViewController managed by a UINavigationController. There's a couple of other editable fields on there to

Re: Fuzzy string matching

2011-06-29 Thread Ulf Dunkel
Hi Eric. I have an application (iOS) that is doing speech to text. The resulting string I'd like to fuzzy match against the user's onboard music library, and play a song, album, genre, etc. as appropriate. I am looking for a really good fuzzy string matching engine. I found this: http://www.loca

Re: How Do I get informed when -showHelp: has been called?

2011-06-29 Thread Ulf Dunkel
I would really like to get a hint on this. Even a simple "not possible" would help. Thank you. :-) - - - - - Am 27.06.2011 22:58, schrieb Ulf Dunkel: In a simple app of mine, I use the standard Help menu and MyApp Help menu item, which is bound to -showHelp:. I would like to have my AppDelega

Re: problem with applying md5 to data

2011-06-29 Thread Wilker
Thanks Quincey, these things for sure will be a lot helpful, Im still pretty new to Objective-C, but I will look in all of those things that you said, thanks :) --- Wilker Lúcio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 On Wed, Jun 29, 2011 at 5:13 AM, Quincey Morris wro

Re: Fuzzy string matching

2011-06-29 Thread Eric E. Dolecki
Thanks for the reply, I've now found this: http://www.merriampark.com/ldobjc.htm Will try this out and see how it goes. It's close to something I already had which I didn't think worked that great, but will try anyway. Eric On Wed, Jun 29, 2011 at 9:19 AM, Ulf Dunkel wrote: > Hi Eric. > >> I

Re: Properties, Attributes and Retain+Autorelease

2011-06-29 Thread Markus Hanauska
On 2011-06-29, at 13:58 , Fritz Anderson wrote: > Apple may be (and probably is) using methods more primitive than > retain/release/autorelease. It may (probably has, and very probably will) > change the implementation between point releases of the operating system. This is absolutely obviou

Re: problem with applying md5 to data

2011-06-29 Thread Wilker
Quincey, I did some changes following your recommendations, this is my current version: +(NSString *)generateHashFromPath:(NSString *)path { const NSUInteger CHUNK_SIZE = 65536; NSData *fileData = [NSData dataWithContentsOfFile:path options:NSDataReadingMapped | NSDataReadingUncached error

Re: How Do I get informed when -showHelp: has been called?

2011-06-29 Thread Angus Hardie
On 29 Jun 2011, at 14:22, Ulf Dunkel wrote: > I would really like to get a hint on this. Even a simple "not possible" would > help. Thank you. :-) > > - - - - - > > Am 27.06.2011 22:58, schrieb Ulf Dunkel: >> In a simple app of mine, I use the standard Help menu and MyApp Help >> menu item, wh

Re: How Do I get informed when -showHelp: has been called?

2011-06-29 Thread Gerd Knops
On Jun 29, 2011, at 8:22 AM, Ulf Dunkel wrote: > I would really like to get a hint on this. Even a simple "not possible" would > help. Thank you. :-) > > - - - - - > > Am 27.06.2011 22:58, schrieb Ulf Dunkel: >> In a simple app of mine, I use the standard Help menu and MyApp Help >> menu item,

RE: Fuzzy string matching

2011-06-29 Thread Shawn Bakhtiar
Just out of curiosity... Why not use extended regular expressions? Or am I missing something? > From: edole...@gmail.com > Date: Wed, 29 Jun 2011 09:33:44 -0400 > To: dun...@calamus.net > CC: cocoa-dev@lists.apple.com > Subject: Re: Fuzzy string matching > > Thanks for the reply, I've now fo

Re: who is currently the first responder? (iOS)

2011-06-29 Thread Matt Neuburg
On Wed, 29 Jun 2011 21:12:50 +0800, Roland King said: >Is there a way to find out what UIResponder is the current first responder, >the one with the keyboard up? No. I devote some space to ranting about this in my book. The app obviously *knows* who the first responder is, so why won't it tell

Re: How to assign a method for touch event to a UIImageView?

2011-06-29 Thread Matt Neuburg
On Fri, 24 Jun 2011 22:26:42 +0200, Jonathan Chac?n Barbero said: > >I want to execute a method when the user touches a UIImageView. In my book, I actually give a solution to this (in the Touch Delivery section of the Touches chapter): set the UIImageView's userInteractionEnabled to YES and at

Re: Properties, Attributes and Retain+Autorelease

2011-06-29 Thread Matt Neuburg
On Wed, 29 Jun 2011 12:53:26 +0200, Markus Hanauska said: >E.g. consider the following code: > > ObjectCreator oc = [[ObjectCreator alloc] init]; > id value = [oc value]; > [oc release]; > [value someMethod]; > We actually had something very like this discussion here alrea

Re: who is currently the first responder? (iOS)

2011-06-29 Thread Roland King
On 29-Jun-2011, at 11:56 PM, Matt Neuburg wrote: > On Wed, 29 Jun 2011 21:12:50 +0800, Roland King said: >> Is there a way to find out what UIResponder is the current first responder, >> the one with the keyboard up? > > No. I devote some space to ranting about this in my book. The app obviou

Re: who is currently the first responder? (iOS)

2011-06-29 Thread Alex Kac
File a doc bug :) -- Alex Kac CEO/Founder On Jun 29, 2011, at 11:10 AM, Matt Neuburg wrote: > Actually it works for more than text fields; another case of poor > documentation. m. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do no

Activate app but bring only *one* window to the front

2011-06-29 Thread Jerry Krinock
• App is running with several windows open but is not frontmost. • It receives an interapplication message which requires that a new window be opened and brought to the front. -[NSApplication activateIgnoringOtherApps:] brings *all* of app's windows to the front. How can I activate this app but

Re: Properties, Attributes and Retain+Autorelease

2011-06-29 Thread Markus Hanauska
On 2011-06-29, at 18:09 , Matt Neuburg wrote: > As I said then, "Ownership is *never* something you are magically given. Since when do you have to be owner of an object to be allowed to interact with it? This contradicts pretty much everything Apple has ever documented about Cocoa/Obj-C. Fol

Re: Activate app but bring only *one* window to the front

2011-06-29 Thread Kyle Sluder
On Wed, Jun 29, 2011 at 10:07 AM, Jerry Krinock wrote: > • App is running with several windows open but is not frontmost. > • It receives an interapplication message which requires that a new window be > opened and brought to the front. > > -[NSApplication activateIgnoringOtherApps:] brings *all*

Re: Activate app but bring only *one* window to the front

2011-06-29 Thread Kyle Sluder
On Wed, Jun 29, 2011 at 10:11 AM, Kyle Sluder wrote: > Never tried it, but +[NSRunningApplication activateWithOptions:] looks > promising. Er, make that -[NSRunningApplication activateWithOptions:]. Combine that with +[NSRunningApplication currentApplication]. --Kyle Sluder _

Re: Properties, Attributes and Retain+Autorelease

2011-06-29 Thread Kyle Sluder
On Wed, Jun 29, 2011 at 10:08 AM, Markus Hanauska wrote: > Since when do you have to be owner of an object to be allowed to interact > with it? You're holding on to the result of -value. Therefore you need an ownership reference to it. This is something Cocoa programmers have needed to worry ab

Re: Properties, Attributes and Retain+Autorelease

2011-06-29 Thread Markus Hanauska
On 2011-06-29, at 18:09 , Matt Neuburg wrote: > As I said then, "Ownership is *never* something you are magically given. Actually I have to correct my previous statement, since it is incorrect. I said: Following your reasoning, Apple has to re-design Cocoa and re-write all guides and sample co

Re: Properties, Attributes and Retain+Autorelease

2011-06-29 Thread Markus Hanauska
On 2011-06-29, at 19:17 , Kyle Sluder wrote: > http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmPractical.html%23//apple_ref/doc/uid/TP40004447-1000922-BABBFBGJ Yes, it talks about certain*exceptions*, and you are right, one of them is in fact destro

Re: problem with applying md5 to data

2011-06-29 Thread Quincey Morris
On Jun 29, 2011, at 07:08, Wilker wrote: > char buffer[CHUNK_SIZE]; > [fileData getBytes:buffer range:NSMakeRange(0, CHUNK_SIZE)]; > CC_MD5_Update(&md5, buffer, CHUNK_SIZE); > [fileData getBytes:buffer range:NSMakeRange(MAX(0, [fileData length] - > CHUNK_SIZE), CHUNK_SIZE)]; >

Re: Properties, Attributes and Retain+Autorelease

2011-06-29 Thread Eeyore
Still learning Cocoa myself, so hoping to be corrected if I'm wrong. On Jun 29, 2011, at 10:39 AM, Markus Hanauska wrote: > "Cocoa’s ownership policy specifies that received objects should typically > remain valid throughout the scope of the calling method. It should also be > possible to retur

Re: problem with applying md5 to data

2011-06-29 Thread Wilker
Thanks again Quincey. Just for curiousity, if I do the line: const uint8_t* buffer = [fileData bytes]; it will not read the entire file? or these address are pointed direct on disk so they are load on demand? also, just to mean if I understand here: CC_MD5_Update(&md5, buffer + byteOffset, byt

Re: Properties, Attributes and Retain+Autorelease

2011-06-29 Thread Kyle Sluder
On Wed, Jun 29, 2011 at 10:39 AM, Markus Hanauska wrote: > Yes, it talks about certain*exceptions*, and you are right, one of them is in > fact destroying the parent, so I'm wiling to accept that you must not rely > upon an object to stay alive longer than its parent.  However, have you also >

Display Letterboxing Pillarboxing

2011-06-29 Thread Richard Somers
In System Preferences a user may select a specific display resolution. Some display resolutions will stretch the visible area to fill the display as needed. But some display resolutions will pillarbox where a black bar is placed on the left and right of the visible area. Is it possible to progr

Re: Properties, Attributes and Retain+Autorelease

2011-06-29 Thread Markus Hanauska
On 2011-06-29, at 20:08 , Matt Neuburg wrote: > On Jun 29, 2011, at 10:39 AM, Markus Hanauska wrote: > >> If that was allowed, one would have to write code like this: >> >> id value = [someObject value]; >> [value retain]; >> [someOtherObject setValue:value]; >> [value relea

Re: problem with applying md5 to data

2011-06-29 Thread Quincey Morris
On Jun 29, 2011, at 11:32, Wilker wrote: > Just for curiousity, if I do the line: > > const uint8_t* buffer = [fileData bytes]; > > it will not read the entire file? or these address are pointed direct on disk > so they are load on demand? [fileData bytes] is a pointer to some memory address

Re: problem with applying md5 to data

2011-06-29 Thread Wilker
Nice :) This is my latest code, I mean it should be right now, hehe (and yeth, Im using GC): +(NSString *)generateHashFromPath:(NSString *)path { const NSUInteger CHUNK_SIZE = 65536; NSError *error = nil; NSData *fileData = [NSData dataWithContentsOfFile:path options:NSDataReadingMap

Re: Display Letterboxing Pillarboxing

2011-06-29 Thread Nick Zitzmann
On Jun 29, 2011, at 1:04 PM, Richard Somers wrote: > In System Preferences a user may select a specific display resolution. > > Some display resolutions will stretch the visible area to fill the display as > needed. But some display resolutions will pillarbox where a black bar is > placed on t

Re: Properties, Attributes and Retain+Autorelease

2011-06-29 Thread Quincey Morris
On Jun 29, 2011, at 12:08, Markus Hanauska wrote: > I personally think a getter should always [snip] ... You know, in the Cocoa world, we play with live ammo. When we are handed a pointer without ownership, we go ahead and use it for a while without taking ownership. For as long as we do that,

Re: problem with applying md5 to data

2011-06-29 Thread Quincey Morris
On Jun 29, 2011, at 12:26, Wilker wrote: > +(NSString *)generateHashFromPath:(NSString *)path { > const NSUInteger CHUNK_SIZE = 65536; > > NSError *error = nil; > NSData *fileData = [NSData dataWithContentsOfFile:path > options:NSDataReadingMapped | NSDataReadingUncached error:&e

Re: Help with relationship objects

2011-06-29 Thread Brad Stone
Quincey, that helps. Thanks On Jun 28, 2011, at 1:36 PM, Quincey Morris wrote: > On Jun 28, 2011, at 08:40, Brad Stone wrote: > >> I get the below. Notice the new SRTodoEntity is properly in the todos >> relationship but there's also a reference to it outside of the SRNoteEntity. >> Intuiti

Using Multi-Gesture events with Carbon

2011-06-29 Thread Abdul Sowayan
Hi folks, I have a carbon based application that we are converting overtime to Cocoa. What I would like to do, if possible, is to incorporate multi-gesture events (such as magnify event) into my carbon application. I can see that NSResponder has magnifyWithEvent: selector. I am wondering if the

Re: problem with applying md5 to data

2011-06-29 Thread Wilker
Thanks :) I will make the conversion to CC_LONG to be more clear, but about the bug, I mean it will be impossible to happen on this case, since the max length will be always 64kb :) About the remote thing, I mean its more low level things, the HD is just mounted as an Volume (on /Volumes/Wilker-1

Receive custom url without bringing app to front?

2011-06-29 Thread Jerry Krinock
When I install a custom URL handler like this: NSAppleEventManager *aem = [NSAppleEventManager sharedAppleEventManager] ; [aem setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL] ; even if

dealloc and scarce resources

2011-06-29 Thread James Merkel
In another thread, someone referenced the Memory Management Programming Guide: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ MemoryMgmt/Articles/mmPractical.html%23//apple_ref/doc/uid/ TP40004447-1000922-BABBFBGJ In the Guide it says: "You should typically not manag

Re: Receive custom url without bringing app to front?

2011-06-29 Thread Ken Thomases
On Jun 29, 2011, at 7:32 PM, Jerry Krinock wrote: > When I install a custom URL handler like this: > > NSAppleEventManager *aem = [NSAppleEventManager sharedAppleEventManager] ; > [aem setEventHandler:self > andSelector:@selector(handleGetURLEvent:withReplyEvent:) > forEventClass:kI

Re: dealloc and scarce resources

2011-06-29 Thread Wim Lewis
On 29 Jun 2011, at 5:43 PM, James Merkel wrote: > In the [Memory Management Programming Guide] it says: > > "You should typically not manage scarce resources such as file descriptors, > network connections, and buffers or caches in a dealloc method. In > particular, you should not design classe

Re: dealloc and scarce resources

2011-06-29 Thread James Merkel
On Jun 29, 2011, at 7:17 PM, Wim Lewis wrote: On 29 Jun 2011, at 5:43 PM, James Merkel wrote: In the [Memory Management Programming Guide] it says: "You should typically not manage scarce resources such as file descriptors, network connections, and buffers or caches in a dealloc method.

Re: dealloc and scarce resources

2011-06-29 Thread Quincey Morris
On Jun 29, 2011, at 17:43, James Merkel wrote: > "You should typically not manage scarce resources such as file descriptors, > network connections, and buffers or caches in a dealloc method. In > particular, you should not design classes so that dealloc will be invoked > when you think it will

Re: dealloc and scarce resources

2011-06-29 Thread James Merkel
On Jun 29, 2011, at 9:47 PM, Quincey Morris wrote: On Jun 29, 2011, at 17:43, James Merkel wrote: "You should typically not manage scarce resources such as file descriptors, network connections, and buffers or caches in a dealloc method. In particular, you should not design classes so th

NSUndoManager - unstable state

2011-06-29 Thread livinginlosangeles
Is there a way to check if the NSUndomanager is in an unstable state and reset it? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at

Quicklook thumbnails vs previews, API for previews?

2011-06-29 Thread Oleg Krupnov
Hi, The QuickLook API documentation defines and contrasts "thumbnails" and "previews", but all I see on the client side is the only function QLThumbnailImageCreate. I assume this is for creating "thumbnails", isn't it? In that case, how do I create "previews" on the client side? Alternatively, if

Re: dealloc and scarce resources

2011-06-29 Thread Kyle Sluder
On Wed, Jun 29, 2011 at 10:38 PM, James Merkel wrote: > Ok, thanks. For what I'm doing file descriptors are not a scarce resource. File descriptors are almost always a scarce resource. By default, each process only gets 256 of them. --Kyle Sluder ___

Re: NSUndoManager - unstable state

2011-06-29 Thread Kyle Sluder
On Wed, Jun 29, 2011 at 10:40 PM, wrote: > Is there a way to check if the NSUndomanager is in an unstable state and > reset it? No, NSUndoManager is very fragile, and if it gets into a bad state it is not recoverable. --Kyle Sluder ___ Cocoa-dev mai

Re: dealloc and scarce resources

2011-06-29 Thread James Merkel
On Jun 29, 2011, at 11:07 PM, Kyle Sluder wrote: On Wed, Jun 29, 2011 at 10:38 PM, James Merkel wrote: Ok, thanks. For what I'm doing file descriptors are not a scarce resource. File descriptors are almost always a scarce resource. By default, each process only gets 256 of them. --Kyle S