Note that there are some explanatory texts on larger screens.

plurals
  1. POHex in a stringWithFormat BAD ACCESS
    primarykey
    data
    text
    <p>Here is a part of my code:</p> <p>I have a string which is formed by a stringWithFormat like this:</p> <pre><code>NSString * DestChoice = [NSString stringWithFormat:@"%@", Dest1String]; </code></pre> <p>The Dest1String is formed like this:</p> <pre><code>NSString * Dest1String = [NSString stringWithFormat:@"%lX", [Dest1OutField integerValue]]; </code></pre> <p>The Dest1OutField is a NSTextField</p> <p>When I put "10" in my text field, the DestChoice string result in "A" so my code is working. When I put "11" in my text field, the DestChoice string result in "B", this is good too. But If put "31" i'm supposed to get "1F" but I have a "EXC_BAD_ACCESS" crash...</p> <p>I don't understand... If someone can light my way... :)</p> <p>Thans in advance!</p> <hr> <p>EDIT:</p> <p>So, I'm always stuck... I edited my code to be "more understandable" and I give you the exact code which I use, not an sample:</p> <p>So, I make two strings like this:</p> <pre><code>DestChoice = [NSString stringWithFormat:@"%lX", [DestField integerValue]]; SourceChoice = [NSString stringWithFormat:@"%lX", [SourceField integerValue]]; </code></pre> <p>So the user write the Source/Dest in Decimal value but they are stocked as hex in a string, and then I have a button which reformat the source &amp; dest like this:</p> <pre><code>NSString * CommandReadyToSend = [NSString stringWithFormat:@"X:0/%@,%@\r", DestChoice, SourceChoice]; </code></pre> <p>My code is working, BUT, strangly some values makes a EXC_BAD_ACCESS at the CommandReadyToSend part... Example: If I write 1 in my text field => I receive 1 (hex value) as result in DestChoice If I write 10 in my text field => I receive A in DestChoice</p> <p>BUT If I write 31 in the text field, I'm supposed to get 1F, but I get a EXC_BAD_ACCESS... Same thing with 29 (dec value)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload