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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Add unretained object to an array perrien Mac Programming 4 Oct 21, 2011 11:29 PM
How to update NSArrayController and TableViews when objects added to Array? klaxamazoo Mac Programming 0 Mar 14, 2011 05:11 PM
loop, objects and array wierdness kristiaand Mac Programming 4 Nov 6, 2008 05:33 PM
adding/removing objects from an array Darkroom Mac Programming 3 Jun 5, 2008 11:31 AM
Is there any way to modify a null object in an Array? bigrell486 Mac Programming 1 Apr 15, 2007 04:40 PM


All times are GMT -5. The time now is 10:41 AM.

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

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