New to iPhone: I have some questions

Apprentice
Posts: 9
Joined: 2008.07
Post: #1
Hello guys,

I'm a mobile game developer (already worked on J2ME and Symbian phones), and now I'm getting started with iPhone.
But I never worked on Apple plateforms, so I'm discovering Cocoa, Xcode, Objective C and all this stuff.

I created a OpenGL-ES project with the iPhone sdk, and I'm trying to add my own sprite class. But I'm meeting some difficulties:
- I can't include my header file in other files (error: no such file or directory), is there a special syntax in ObjC ?
- What does exactly mean the "-" in front of a method declaration ?
- I saw I could use either CoreGraphics or OpenGL-ES for 2D drawing, which method is the fastest ? (I only have the iPhone emulator, not yet the handset).

Thanks in advance for your answers !
Quote this message in a reply
Member
Posts: 59
Joined: 2007.12
Post: #2
OpenGL ES should be very fast for 2D drawing.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #3
Read all of the Getting Started documentation and the Objective C primer.
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #4
I believe there are some introductory videos too, which are worth checking out for some easy orientation.
Quote this message in a reply
Apprentice
Posts: 9
Joined: 2008.07
Post: #5
Hi,

well I registered at the ADC and I'm studying videos and documentation to get started.
Thanks for your answers.
Quote this message in a reply
Member
Posts: 215
Joined: 2008.06
Post: #6
Xavier Wrote:Hello guys,

I'm a mobile game developer (already worked on J2ME and Symbian phones), and now I'm getting started with iPhone.
But I never worked on Apple plateforms, so I'm discovering Cocoa, Xcode, Objective C and all this stuff.

I created a OpenGL-ES project with the iPhone sdk, and I'm trying to add my own sprite class. But I'm meeting some difficulties:
- I can't include my header file in other files (error: no such file or directory), is there a special syntax in ObjC ?
- What does exactly mean the "-" in front of a method declaration ?
- I saw I could use either CoreGraphics or OpenGL-ES for 2D drawing, which method is the fastest ? (I only have the iPhone emulator, not yet the handset).

Thanks in advance for your answers !

In case your questions still linger Xavier, and for those of you who are reading this thread in hope of answers:

1. Objective-C and Apple's coding guidelines generally use the #import statement to bring in source files and other packages. Use #import <*package*> for non-project local files, and #import "*file.h*" for source files you have dragged and dropped into your application.

2. Objective-C uses a different kind of syntax for method declaration. A "-" in front of a method indicates that it is an instance method, meaning that an instantiated instance of the class can call that method. A "+" in front of the method means it is a class method, meaning the abstract class is called to perform it. If you have more questions on this, post here.

3. In general, OpenGL ES is MUCH faster for drawing images and animations, but CoreGraphics allows for better and easier abstraction of such graphics into class/object format and also has much better and easier interfacing and interaction with the other Apple provided APIs.

Hope that answered your question. Good luck!

Mac users swear by their computers, PC users swear at their computers. ~Unknown

iSayz
Quote this message in a reply
Apprentice
Posts: 9
Joined: 2008.07
Post: #7
Thanks Talyn for the infos.

I'm now trying to write some data in a file, but it doesn't work yet.

Quote:- (BOOL)writeToFile:(NSData *)data:(NSString *)fileName:(NSString *)extension
{
NSString* appFile = [[NSBundle mainBundle] pathForResource:fileName ofType:extension];

if (!appFile) // file doesn't exist
{
return NO;
}
else
return ([data writeToFile:appFile atomically:NO]);
}

My method returns a YES, but nothing is written in the file.

Did you already tried the NSData : writeToFile method ?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #8
I don't know how it works on the iPhone, but on the Mac you should not assume you have permission to write to your application bundle.
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #9
On an entirely unrelated note, is it possible to turn off smilies inside code tags on a forum-wide basis?

Also, writing to your application bundle is a bad idea. On Macs, the app might reside in /Applications, but the user might not be a superuser and therefore would not have write privileges (unless they were expressely enabled). The iphone is probably different, seeing as you're running effectively as root (from what I gather), but access is NOT GUARANTEED. The best way to do it is to either use Apple's built-in preferences or write your own files to ~/Library/Application\ Support/YOUR_APP_HERE (again, not sure if it's done this way on the iphone.)

Cheers! -duane.

It's not magic, it's Ruby.
Quote this message in a reply
Member
Posts: 215
Joined: 2008.06
Post: #10
It has come to my attention that although this post may have been helpful, the terms of use regarding the iPhone SDK may put me, my employees, and my application into a legal bind should this post remain. So, until the iPhone SDK is released from the Apple Confidential Information agreement to which I conform, further informative posts by myself, my employees, or anyone using the SDK at this time should be reconsidered as a breach of contract. My sincerest apologies. I will be happy to help when legal recourse no longer prevents me from doing so.

Mac users swear by their computers, PC users swear at their computers. ~Unknown

iSayz
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #11
Can't help you on iPhone audio because of NDA, sorry. Maybe tomorrow. Post a thread on it when we get out of NDA.

In the meantime, on the Mac, I would suggest using OpenAL for short sounds like explosions and laser/gunfire, etc. For background music you can use Audio Queues on Mac OS X 10.5 or greater.

If you are talking about trying to understand using Audio Queues on Mac OS X 10.5 (I am NOT talking about iPhone, because it cannot be discussed as to whether or not it even has Audio Queues) then yes, it is convoluted and difficult to approach -- *especially* the example code.
Quote this message in a reply
Moderator
Posts: 700
Joined: 2002.04
Post: #12
Thread split as requested: Audio Queues.

Mark Bishop
--
Student and freelance OS X & iOS developer
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  iPhone Emulator / Leopard Questions Nick 6 5,492 Aug 8, 2008 11:02 AM
Last Post: Nick