Home
Reviews
Forums
New Games
Podcast
• submit tip •
  #1  
Old 07-08-2012, 11:51 AM
Evre1 Evre1 is offline
Junior Member
iPhone 4S, iOS 5.x
 
Join Date: Jul 2012
Posts: 1
Default Please help me with some simple code

I just want to make a simple program that displays a message on my iPhone screen. I've been following the guide at http://www.cocoalab.com/BecomeAnXcoder

and I put some of their example code into the main.m file in my Xcode software, and when I run the simulator all I get is either a blank screen or the app just closes and doesn't run.

How can I get this code to work?


#import <Foundation/Foundation.h>
float circleArea(float theRadius);
float rectangleArea(float width, float height);
int main()
{
float pictureWidth, pictureHeight, pictureSurfaceArea,
circleRadius, circleSurfaceArea;
pictureWidth = 8.0;
pictureHeight = 4.5;
circleRadius = 5.0;
pictureSurfaceArea = rectangleArea(pictureWidth, pictureHeight);
circleSurfaceArea = circleArea(circleRadius);
NSLog(@"Area of circle: %10.2f.", circleSurfaceArea);
NSLog(@"Area of picture: %f. ", pictureSurfaceArea);
return 0;
}
float circleArea(float theRadius) // first custom function
{
float theArea;
theArea = 3.1416 * theRadius * theRadius;
return theArea;
}
float rectangleArea(float width, float height) // second custom function
{
return width*height;
}

I just want to find some code that produces a result so I can build from that knowledge.

If I put that into the main.m the app just closes when I run it.
Reply With Quote
  #2  
Old 07-08-2012, 12:40 PM
ruiznick ruiznick is offline
Junior Member
iPhone 4S, iOS 5.x
 
Join Date: Mar 2012
Location: California
Posts: 27
Default

To get a basic understanding of programming, I suggest following along with http://thenewboston.org/list.php?cat=33

After you build up that knowledge and are interested in making games, then I suggest following some cocos2D tutorials.

If programming is very new to you and are lost in the woods, then I would suggest skipping objective-c and starting with Unity. You will still build that basic foundation of understanding, but Unity is more visual and there are a lot of resources to get into it quickly. Another plus about Unity is that its multi-platform.
Reply With Quote

Reply

Thread Tools
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


iPhone Game Reviews | iPhone Apps

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