Re: [Mysql-cocoa-users] prepareString and quoteObject (solution)
Brought to you by:
sergecohen
|
From: Jim H. <che...@ho...> - 2004-11-21 20:57:34
|
Thanks, Serge! You are right, I was using retain needlessly. I was forgetting that the retain counter is already at 1. The difference between class and instance methods was indeed my main problem also. Here's another question that's related. When I use the prepareString: method on a string that contains a hyphen, it exceptions and quits. When I remove the prepareStrings it works fine. It only seems to happen on this one particular case where the string contains two words seprated by hyphen. Example: "jwisen-ap1g1r2" Is there something in the prepareString method that would be causing this, or am I doing something else wrong? (This string would be among the strings I used in my example before.) Thanks again, -JH >From: Serge Cohen <ser...@us...> >To: "Jim Hall" <che...@ho...> >CC: mys...@li... >Subject: Re: [Mysql-cocoa-users] prepareString and quoteObject (solution) >Date: Wed, 17 Nov 2004 11:37:31 +0100 > >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > >Hi Jim; > >Sorry not ot have answered before... anyway you got a correct answer from >another user of the list (difference between class and instance methods). >If I'm sending this reply it is because I think there is something wrong >in the code snippet you send to the list : > >>MCPConnection *aQueryConnection = [[[MCPConnection alloc] init] retain]; > >An object which is just alloc then init does NOT need to be retained >because it's retain count is already set to 1, so unless you're trying to >do something unusual you would just not need to call the 'retain' method. > >For more information on how to use alloc, init, retain, release and >autorelease a very good reference is Apple documentation : >http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/ >index.html >http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaObjects/ >index.html > >Hope this will help you... > >Serge. > >Le 17 nov. 04, à 00:51, Jim Hall a écrit : > >>I figured it out! (duh, it should have been obvious) >> >>For those of you searching the archives with a similar problem, try using >>it like this: >> >>MCPConnection *aQueryConnection = [[[MCPConnection alloc] init] retain]; >>MCPConnection *aQueryResult; >>aQueryResult = [aQueryConnection queryString:[NSString >>stringWithFormat:@"insert into table (fieldA,fieldB) values ( '%@', >>'%@')", >>[aQueryConnection prepareString:fieldAString], >>[aQueryConnection prepareString:fieldAString]]]; >> >>Thanks! >>-JH > >******************************************* >Serge Cohen > >GPG Key ID: 9CBB58FB >******************************************* >-----BEGIN PGP SIGNATURE----- >Version: GnuPG v1.2.3 (Darwin) > >iD8DBQFBmynx5EPeG5y7WPsRAh7fAJ4x3jVWGh12THNfqNkd5/lGIiepVgCdFkMV >3H0Z8jTuHmXTs2FWpBIJFk0= >=CASA >-----END PGP SIGNATURE----- > |