Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Fritz Anderson
On 24 May 2012, at 1:57 PM, Jason Teagle wrote: > If the CGContextXXX methods shouldn't be used, then they shouldn't be in the > API - or should be marked as deprecated. There's nothing in the docs (with > Xcode 3.X, at least - maybe it's changed since) to indicate that these were > the worst w

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Jason Teagle
Thanks for all the replies regarding %s vs. %@, and the rather disastrous attempt at using CGContextXXX methods. Even if I had fixed all the other issues, I was using CGContextSelectFont incorrectly anyway. I didn't have a hope. That, unfortunately, is down to documentation not being complete /

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Ken Thomases
On May 24, 2012, at 2:49 AM, Jason Teagle wrote: > First, a quick question about +stringWithFormat: If I want to have a literal > string as one of the parameters to the format, which is correct / best: > > NSString *textToDraw = [NSString stringWithFormat: @"%s", >

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Jens Alfke
On May 24, 2012, at 5:50 AM, Jason Teagle wrote: > (I've since discovered that the %@ and @"xxx" way works just fine, so I'll > stick with that. Good :) The problem with using "%s" is that it doesn't work well with non-ASCII characters. Cocoa has to assume some character encoding to map the by

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Kyle Sluder
On May 24, 2012, at 10:36 AM, Manfred Schwind wrote: >> CGContextShowTextAtPoint(contextRef, 0, 40, >>[textToDraw UTF8String], [textToDraw length]); > > One bug I see here: you're passing a wrong length parameter. Another bug: CGContextShowztextAtPoint takes characters encoded in MacRoman,

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread glenn andreas
On May 24, 2012, at 9:36 AM, Manfred Schwind wrote: >> CGContextShowTextAtPoint(contextRef, 0, 40, >> [textToDraw UTF8String], [textToDraw length]); > > One bug I see here: you're passing a wrong length parameter. > CGContextShowTextAtPoint expects the length of the char array (number of >

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread James Montgomerie
On 24 May 2012, at 15:36, Manfred Schwind wrote: >> CGContextShowTextAtPoint(contextRef, 0, 40, >> [textToDraw UTF8String], [textToDraw length]); > > One bug I see here: you're passing a wrong length parameter. > CGContextShowTextAtPoint expects the length of the char array (number of > byte

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Manfred Schwind
> CGContextShowTextAtPoint(contextRef, 0, 40, > [textToDraw UTF8String], [textToDraw length]); One bug I see here: you're passing a wrong length parameter. CGContextShowTextAtPoint expects the length of the char array (number of bytes of the UTF-8 encoded string), but you'e passing the numb

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Jason Teagle
You probably want UILabel. UITextView is a much more heavyweight class that supports editing as well as display. (My bad, a label is called a TextView on Android - got mixed up.) These both are just wasting CPU cycles and adding extraneous code. Simply use: NSString *textToDraw = @"my stri

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Jason Teagle
Have a look at this doc-page: https://developer.apple.com/library/mac/ipad/#documentation/graphicsimaging/ >conceptual/drawingwithquartz2d/dq_text/dq_text.html It discusses your options when drawing text with Quartz2D, and also mentions >other techniques. >One option of note is the NSString ad

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Conrad Shultz
y aim is to render a particular string in a particular colour, in a > particular font (or, any Sans Serif of the system's choosing would be > enough here) and a particular font size. > > First, a quick question about +stringWithFormat: If I want to have a > literal string as on

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Mikkel Islay
and a particular font size. > > First, a quick question about +stringWithFormat: If I want to have a literal > string as one of the parameters to the format, which is correct / best: > > NSString *textToDraw = [NSString stringWithFormat: @"%s", >"m

stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Jason Teagle
in a particular font (or, any Sans Serif of the system's choosing would be enough here) and a particular font size. First, a quick question about +stringWithFormat: If I want to have a literal string as one of the parameters to the format, which is correct / best: NSString *textToDraw =

Re: NSString stringWithFormat: and strings

2009-07-04 Thread Mac First
On Jul 3, 2009, at 8:27 PM, Andy Lee wrote: On Jul 3, 2009, at 11:20 PM, KK wrote: Hello, I have a NSString (from a property list file) that has the %@ formats in it... So.. I do something like this: NSString *stringFromPlistFile; NSString *newString = [NSString stringWithFormat:stringFrom

Re: NSString stringWithFormat: and strings

2009-07-03 Thread Andy Lee
On Jul 3, 2009, at 11:20 PM, KK wrote: Hello, I have a NSString (from a property list file) that has the %@ formats in it... So.. I do something like this: NSString *stringFromPlistFile; NSString *newString = [NSString stringWithFormat:stringFromPlistFile, @"Hello"]; But that doesn't work...

NSString stringWithFormat: and strings

2009-07-03 Thread KK
Hello, I have a NSString (from a property list file) that has the %@ formats in it... So.. I do something like this: NSString *stringFromPlistFile; NSString *newString = [NSString stringWithFormat:stringFromPlistFile, @"Hello"]; But that doesn't work... Keita

Re: stringWithFormat

2008-10-21 Thread Kyle Sluder
On Mon, Oct 20, 2008 at 3:25 AM, Ron Green <[EMAIL PROTECTED]> wrote: > stringWithFormat: returns an NSString that is autoreleased. I know this > because I read it in Hillegasses book. But since this does not seem to be > covered in the documentation, if I had not read it in a bo

Re: stringWithFormat

2008-10-20 Thread Conor
"You "create" an object using a method whose name begins with “alloc” or “new” or contains “copy” (for example, alloc, newObject, or mutableCopy)." "Many classes provide methods of the form +className... that you can use to obtain a new instance of the class. Often referred to as “conve

Re: stringWithFormat

2008-10-20 Thread Roland King
Ron Green wrote: stringWithFormat: returns an NSString that is autoreleased. I know this because I read it in Hillegasses book. But since this does not seem to be covered in the documentation, if I had not read it in a book, how would I discover that the NSString was autoreleased

stringWithFormat

2008-10-20 Thread Ron Green
stringWithFormat: returns an NSString that is autoreleased. I know this because I read it in Hillegasses book. But since this does not seem to be covered in the documentation, if I had not read it in a book, how would I discover that the NSString was autoreleased

Re: passing argument 1 of 'stringWithFormat:' makes pointer from integer without a cast [SOLVED]

2008-07-21 Thread Michael Swan
Aron & Ken, Yes thank you both that has been driving me crazy mostly because I knew it was something stupid like that. Thank you, Mike Swan "Change itself is not painful it is resistance to change that causes pain." ___ Cocoa-dev mailing list (C

Re: passing argument 1 of 'stringWithFormat:' makes pointer from integer without a cast

2008-07-21 Thread Ken Ferry
The parentheses are not correct in that position. You're using the C comma operator (http://www.eskimo.com/~scs/cclass/int/sx4db.html) and passing one argument to stringWithFormat:, which is the count of the array. That isn't a pointer. -Ken On Mon, Jul 21, 2008 at 9:23 PM, Mi

Re: passing argument 1 of 'stringWithFormat:' makes pointer from integer without a cast

2008-07-21 Thread Aron Nopanen
I think the parens around the argument to stringWithFormat: are causing the compiler to interpret the comma as a C comma operator, which means the result of the first expression (your format string) is ignored, and the result of the second expression ([array count]) is treated as the

passing argument 1 of 'stringWithFormat:' makes pointer from integer without a cast

2008-07-21 Thread Michael Swan
So I have done the standard Google search and clean all targets but neither has helped. I have the following two lines of code: NSLog(@"array count = %i",[array count]); // This works just fine NSString *string = [NSString stringWithFormat:(@"array count

Re: NSString stringWithFormat woes

2008-04-08 Thread Hamish Allan
On Tue, Apr 8, 2008 at 8:33 PM, Stuart Green <[EMAIL PROTECTED]> wrote: > returnString = [NSString stringWithFormat:@"%c-%i-%i-%f", > asciiString, firstDouble, secondDouble, thirdDouble]; You have a format string for character-integer-integer-float/double, not

Re: NSString stringWithFormat woes

2008-04-08 Thread Jack Repenning
On Apr 8, 2008, at 12:33 PM, Stuart Green wrote: returnString = [NSString stringWithFormat:@"%c-%i-%i-%f", asciiString, firstDouble, secondDouble, thirdDouble]; Which is producing a weird output when used outside of an NSLog. Examining each parameter in the debugger shows exac

Re: NSString stringWithFormat woes

2008-04-08 Thread Michael Vannorsdel
Try casting them to ints before formatting: returnString = [NSString stringWithFormat:@"%c-%i-%i-%f", asciiString, (int)firstDouble, (int)secondDouble, thirdDouble]; On Apr 8, 2008, at 1:33 PM, Stuart Green wrote: Hi, I have a string declaration of: returnString =

Re: NSString stringWithFormat woes

2008-04-08 Thread Randall Meadows
On Apr 8, 2008, at 1:33 PM, Stuart Green wrote: Hi, I have a string declaration of: returnString = [NSString stringWithFormat:@"%c-%i-%i-%f", asciiString, firstDouble, secondDouble, thirdDouble]; If asciiString really is an ASCII (null-terminated) string, then you need to use

NSString stringWithFormat woes

2008-04-08 Thread Stuart Green
Hi, I have a string declaration of: returnString = [NSString stringWithFormat:@"%c-%i-%i-%f", asciiString, firstDouble, secondDouble, thirdDouble]; Which is producing a weird output when used outside of an NSLog. Examining each parameter in the debugger shows exactly what I w