• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSString, NSArray, get the characters of one of the NSString in an Array of NSStrings?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString, NSArray, get the characters of one of the NSString in an Array of NSStrings?


  • Subject: Re: NSString, NSArray, get the characters of one of the NSString in an Array of NSStrings?
  • From: Brian Webster <email@hidden>
  • Date: Fri, 13 Jul 2001 12:40:05 -0500

on 7/13/01 11:59 AM, email@hidden at
email@hidden wrote:

> My problem is if I implement this idea in cocoa, I stumble against the
> conversion issue between NSArray and NSString
>
> The assignment is made with statement
>
> drawCharacterOfString =[scrambledRound1PlayStringArray
> objectAtIndex:10];
>
> The compiler accepts that, but if I try to use the follwing statement
> drawString = [ drawCharacterOfString characterAtIndex : i ];
>
> I get a warning:
>
> assignment makes pointer from integer without a cast
>
> and my application quits.
>
>
> But I don't know why?

This is because the characterAtIndex: method doesn't return an object; it
returns a unichar, which is a just a simple two-byte Unicode character. To
get an NSString with just this character, there are two ways to go about
doing it:

1. unichar theChar = [drawCharacterOfString characterAtIndex:i];
NSString *theString = [NSString stringWithCharacters:&theChar length:1];

2. NSString *theString = [drawCharacterOfString
substringWithRange:NSMakeRange(i, 1)];

On another note, I remember seeing a demo or two at WWDC that I believe used
Quartz to render a string along an arbitrary path, like a circle, but I
don't recall exactly how to do it.

--
Brian Webster
email@hidden
http://www.owlnet.rice.edu/~bwebster/


  • Prev by Date: Re: NSMutableString, NSMutableAray, scrambled
  • Next by Date: Re: NSString, NSArray, get the characters of one of the NSString in an Array of NSStrings?
  • Previous by thread: Re: NSPopUpButton Problem
  • Next by thread: interthread communication
  • Index(es):
    • Date
    • Thread