Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 25, 2008, 04:21 PM   #1
kashmoney2006
macrumors regular
 
Join Date: Dec 2007
objective c and arrays

I am trying to create a tic tac toe program in xcode using objective c in an attempt to learn the language. i was wondering if objective c supports 2-D arrays? that is hove i implemented it in previous languanges but cant figure it out in ObjC. in c++ i used something similar to

Code:
 int board[][]
is this possible in ObjC?
kashmoney2006 is offline   0 Reply With Quote
Old Mar 25, 2008, 04:24 PM   #2
SC68Cal
macrumors 68000
 
Join Date: Feb 2006
It's standard C syntax. If you want to get fancy I think the NSArray class would be your other option.
SC68Cal is offline   0 Reply With Quote
Old Mar 25, 2008, 06:41 PM   #3
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: Dallas, TX
NSMutableArray is an object. You can make an NSArray or NSMutableArray of them, if you want to. Those can be arrays of NSNumbers that you store something in. I wouldn't, though.

I don't know what you want to store, exactly, but I think a single dimension array should suffice for this purpose. If you are having a 3x3 array to store board state, i'd say just use a 9 element array. I'd say just have them be chars. Ints are SO big, after all. You can save *27* bytes assuming 32 bit ints. Then you can store 'X','O', or ' '(or '\0' if you prefer).

I am, of course, being facetious. If you really want to be a glutton for punishment, you should store the board state in a single short(2-byte) integer.

-Lee
lee1210 is offline   0 Reply With Quote
Old Mar 25, 2008, 08:16 PM   #4
gnasher729
macrumors G5
 
gnasher729's Avatar
 
Join Date: Nov 2005
Quote:
Originally Posted by kashmoney2006 View Post
I am trying to create a tic tac toe program in xcode using objective c in an attempt to learn the language. i was wondering if objective c supports 2-D arrays? that is hove i implemented it in previous languanges but cant figure it out in ObjC. in c++ i used something similar to

Code:
 int board[][]
is this possible in ObjC?
int board [][]

while not work either in C++ or in C or in Objective-C.

int board [10][10] works in all three languages.
gnasher729 is offline   0 Reply With Quote
Old Mar 25, 2008, 10:48 PM   #5
Shahmeer
macrumors newbie
 
Join Date: Mar 2008
Location: Pakistan
Problem with Socket In Objective-c

hi frndz,
i wana discusss a problem related my Client/server application.
while running properly if i terminate my Server application and then restart,my socket remains busy for about 15 to 30 sec..
do anyone has any idea?
Shahmeer is offline   0 Reply With Quote
Old Mar 25, 2008, 10:57 PM   #6
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: Dallas, TX
Quote:
Originally Posted by Shahmeer View Post
hi frndz,
i wana discusss a problem related my Client/server application.
while running properly if i terminate my Server application and then restart,my socket remains busy for about 15 to 30 sec..
do anyone has any idea?
try posting in a new thread, and maybe posting a code snippet.
lee1210 is offline   0 Reply With Quote
Old Mar 25, 2008, 11:45 PM   #7
Shahmeer
macrumors newbie
 
Join Date: Mar 2008
Location: Pakistan
SORRY, Actually am a beginner and its my 1st...nw i'll tack care....
Shahmeer is offline   0 Reply With Quote
Old Mar 25, 2008, 11:46 PM   #8
Shahmeer
macrumors newbie
 
Join Date: Mar 2008
Location: Pakistan
ok thanks

SORRY, Actually am a beginner and its my 1st post...nw i'll tack care....
Shahmeer is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
arrays? subview or submenu? tacotester1 iPhone/iPad Programming 6 Mar 14, 2014 08:06 PM
Please Help with arrays Bigred101 Mac Programming 7 Mar 13, 2014 07:39 PM
hard drive arrays rdking647 Buying Tips and Advice 2 Dec 6, 2013 08:45 PM
arrays of structs farmerdoug Mac Programming 3 Feb 7, 2013 01:47 PM
Comparing Two Arrays Ides iPhone/iPad Programming 5 Aug 10, 2012 03:56 PM

Forum Jump

All times are GMT -5. The time now is 12:41 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC