This Forum References:
TicTacToe Model Class
I'm having some issues with what I'm assuming is a problem with the scanf function when reading the integers into NSIntegers. At first I thought it to be an error in my code but after comparing the code with the excerside files I couldn't find any errors.
I tried running your compiled version from the excersise files and it ran fine. When i compiled the code in the example files though I get the "Cell is out of range" error is raised when entering any "valid" number combination after compilation. It seems that my gcc version doesn't handle the conversion as well as yours :P
What would be the "correct" way of reading the integers to an NSInteger to make sure the input value is correct?
I'm on OSX Lion btw, using xCode 4 and gcc version: i686-apple-darwin11-llvm-gcc-4.2.
EDIT: Meh, stoooopid. Anyway, by declaring two ints (r and c) I now use these ints to hold the values from the commandline. I then set row = r; and col = c; before making the move. Works great!
Glad it worked out! What do you think of the language so far by the way? What language were you most familiar with before? I'm always curious because it's such a unique implementation of a language the way Apple pulled it off. I'm really on the fence about it..
Hey, thanks for replying!
Coming into programming for a high level perspective, the first language I learned was ActionScript 2 and then 3, I find ObjectiveC suprsingly weird :P. Although I now have known C and some assembly for some time and I am very familiar with OOP from AS3 and Flex, I am having a damn hard time to get my head around the syntax in ObjectiveC.
The API itself with all it's classes and methods seems very good and offer valuable tasks but I find the syntax to be confusing. All these brackets and colons makes it hard to read which is suprising since it seems they really tried hard to name classes and methods in a way that would be like "reading english". I'm sure this is something that takes some getting used to but when you finally learn to read it properly it will be beautiful... or something.
I ran into the same problem. I am running Lion with Xcode 4.2 also. Lion is 64-bit. I replaced
scanf("%d %d", &row, &col);
scanf("%ld %ld", &row, &col);
and it works fine now.
Objective-C is a language that is hard to get used to. The way Apple implements it is different just because... I mean... They're Apple. They have made tons of money on being different just because... It's nice to know, but it is still lagging as a popular language. Now that Adobe has released Flex Mobile I am interested to see if Objective-C drops even lower. When we look at our viewed videos Objective-C is in last place. This surprised us! We thought people would be falling over themselves to learn it, but they're not.
Ditto, hit the same problem...
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64
Sometimes things change.. It would be handy to note this in a comment however. I really felt like I was loosing my mind for a minute untill i checked the forums. Yay @rtfm lol In all seriousness it was very frustrating..
"Profanity is the one language all programmers know best."
Welcome to the WiBit.net forums! Check out our terms and features:
Annoy your friends
Is this something you think someone else would enjoy? Is it not for you, but do you know someone who is down with this type of content? Well share away:
This blog is a reminder that cheating in software development can get you into big trouble. Sometimes developers get really really lazy, OR are pressured to write something using overly simplified data structures. Almost every time this happens you are bitten in the butt! Sometimes the problems show up immediately and other times it may take months or years (especially in integrated systems).
- 1 of 78