Professional Web Applications Themes

Number to String conversion - Mac Programming

Hello: I have looked through the doentation to find an answer to this, I havent gotten any thing to work. I need to take two different numbers (they could be ints or floats) and mix them together with floats. Here is an example: Given two numbers in variables A and B. Make a NSstring that is "x: " ; a ; " y: " ; b so and example string output would be "x: 33.4 y: 66.22" the values is quotes are the strings and the things in between semicolons are the variables in which I want there values to ...

  1. #1

    Default Number to String conversion

    Hello:

    I have looked through the doentation to find an answer to this, I havent
    gotten any thing to work. I need to take two different numbers (they could
    be ints or floats) and mix them together with floats. Here is an example:

    Given two numbers in variables A and B. Make a NSstring that is

    "x: " ; a ; " y: " ; b

    so and example string output would be "x: 33.4 y: 66.22"
    the values is quotes are the strings and the things in between semicolons
    are the variables in which I want there values to be mixed in the string.

    In regular C this is easy to do, but with cocoa/objective C I am not sure
    how to do this.

    Thanks


    Eli Guest

  2. #2

    Default Re: Number to String conversion

    Eli Hughes <edu> wrote:
     

    If you know how to do it in "regular C" then you know how to do it in
    Cocoa. See on -[NSString stringWithFormat:]. The formats are essentially
    just like printf. The docs are on your computer. Example:

    <file:///Developer/Doentation/Cocoa/Conceptual/DataFormatting/Tasks/F
    ormatStrings.html>

    m.


    --
    matt neuburg, phd = com, http://www.tidbits.com/matt/
    AppleScript: The Definitive Guide
    http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
    Read TidBITS! It's free and smart. http://www.tidbits.com
    matt Guest

  3. #3

    Default Re: Number to String conversion

    In article <c8032k$17e0$cac.psu.edu>, edu says... 

    Take a look at the NSString class method 'stringWithFormat' which lets
    you build up a string using printf style foramtting strings.
    James Guest

Similar Threads

  1. #39126 [NEW]: String->float->String conversion behavior
    By bobson at rpg dot pl in forum PHP Bugs
    Replies: 2
    Last Post: October 11th, 04:13 PM
  2. Simple String Conversion?
    By Gary in forum ASP.NET Web Services
    Replies: 2
    Last Post: February 15th, 12:32 PM
  3. String to unixtimestamp conversion.
    By Andy Jenkins in forum PERL Beginners
    Replies: 0
    Last Post: February 15th, 10:31 PM
  4. String conversion function
    By Simon Fredriksson in forum PHP Development
    Replies: 1
    Last Post: July 9th, 08:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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