newbie simple strings question

Ask a Question related to Mac Programming, Design and Development.

  1. #1

    Default newbie simple strings question

    I got tired of typing CFSTR so I thought I would just pass a char string
    and convert it to a CFString. The Mac OS X Programming book is very light
    on explanation of strings (need book recommendations).

    Why doesn't this work?

    int tryText(char *psTxt)
    {
    CFMutableStringRef sTxt;
    CFStringAppendCString( sTxt, psTxt, CFStringGetSystemEncoding() );
    return 0;
    }

    Program received signal: "EXC_BAD_ACCESS".

    TIA!
    Frank Guest

  2. Similar Questions and Discussions

    1. [XML::Simple-2.12] problems parsing non ASCII strings
      Jul wrote: Wahouh! Do you know how old this is? 5, 6 years old? What is the encoding of your file? My guess is that it is in either...
    2. Simple Newbie question
      I am comtemplating learning flash, but since I will NEVER let ms windows near my harddrive again, I wanted to know if there is a way to write flash...
    3. Simple Question for a newbie
      I have a flash animation with buttons, which will reside inside a web page. How do I call other pages within the website from each button? For...
    4. Simple Question: Converting lists to strings
      Is there a way to use a list in a case statement? Can I substitute myList = in the case statement below? case(myVar) of 1, 4, 6, 9, 11:...
    5. Newbie with a simple question.
      Why does one of my pages on my site flash on and off? What have I done? hahah. website: www.chameleonentertainment.com page: Meet the Band ...
  3. #2

    Default Re: newbie simple strings question

    In article <no-3009031947230001@eli-216-190-254-129.ev1.net>,
    [email]no@spam.com[/email] (Frank) wrote:
    > int tryText(char *psTxt)
    > {
    > CFMutableStringRef sTxt;
    sTxt = CFStringCreateMutable(kCFAllocatorDefault, 0);
    > CFStringAppendCString( sTxt, psTxt, CFStringGetSystemEncoding() );
    > return 0;
    > }
    >
    > Program received signal: "EXC_BAD_ACCESS".
    You haven't actually created a mutable string yet, you only defined a
    space in memory for one. Add what I added above, and it should work fine
    (I think! I haven't used CF much). You can replace 0 with a max length
    for the string if you want.

    Doug

    --
    Doug Brown - La Grande, OR - [url]http://www.ircandy.com/doug/[/url]
    Idiot's Guide to Mac Cases - [url]http://www.ircandy.com/maccases/[/url]
    If you want to reply by email, remove "pleasenospam." and ".invalid"
    Doug Brown Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139