Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Does anyone know how to fix this error?

  • Yes ;) I'll help

    Votes: 1 100.0%
  • No Sorry I don't know ;(

    Votes: 0 0.0%

  • Total voters
    1
  • Poll closed .

AlexTheXcodeProgrammer

macrumors newbie
Original poster
Oct 11, 2015
10
0
Hi, I'm new to Xcode programming and stuff but there's a weird bug fix that needs correcting. I don't know what it is, but the error says 'Expected declaration'. I've removed a curly-bracket, and it messed the whole code so I put it back, but i don't know what to do. I've uploaded a screenshot. Thanks for replying! :)
 

Attachments

  • Screen Shot 2015-10-11 at 21.30.35.png
    Screen Shot 2015-10-11 at 21.30.35.png
    49.7 KB · Views: 691

JWalker1995

macrumors regular
Mar 5, 2011
224
3
after self.physicsworld.gravity, you need to delete the next three curly brackets. the first one after self.physicsworld.gravity closes the method, so then the next opening should have a method before it, so it is 'expecting declaration' of the method. just delete the three brackets and it should work fine :)
 

AlexTheXcodeProgrammer

macrumors newbie
Original poster
Oct 11, 2015
10
0
after self.physicsworld.gravity, you need to delete the next three curly brackets. the first one after self.physicsworld.gravity closes the method, so then the next opening should have a method before it, so it is 'expecting declaration' of the method. just delete the three brackets and it should work fine :)


Hi! Thanks for answering, but unfortunately it doesn't work. When I delete the first three curly-brace bracket the whole code becomes red with errors and I don't understand what's happening! :(

Hi Thanks for answering! Unfortunately it didn't work for me because when I delted the first three brackets after self.physiscsWorld.gravity =CGVectorMake(0.0, -0.5), when I run it the whole page becomes red with errors! I don't understand please help :(
 
Last edited by a moderator:

mfram

Contributor
Jan 23, 2010
1,345
386
San Diego, CA USA
There's a strange mix of Swift and Objective-C there. Even if there weren't problems with braces the code doesn't mean anything. Which language are you intending to use?
 

AlexTheXcodeProgrammer

macrumors newbie
Original poster
Oct 11, 2015
10
0
Hi Thanks for answering! Unfortunately it didn't work for me because when I delted the first three brackets after self.physiscsWorld.gravity =CGVectorMake(0.0, -0.5), when I run it the whole page becomes red with errors! I don't understand please help :(
There's a strange mix of Swift and Objective-C there. Even if there weren't problems with braces the code doesn't mean anything. Which language are you intending to use?


I'm intending to use SpriteKit
 

DannyBres

macrumors 65816
Oct 30, 2007
1,412
6
UK
I'm intending to use SpriteKit
That isn't a language. You need to pick Objective-C or Swift for Xcode development.

Pasted_Image_16_10_2015__07_18.png


Either this code is half finished or you do not grasp the concept of the language, it is all Objective-C (except the C function CGVectorMake()).

I am around all day today, happy to help if you have more questions.
 

AlexTheXcodeProgrammer

macrumors newbie
Original poster
Oct 11, 2015
10
0
That isn't a language. You need to pick Objective-C or Swift for Xcode development.

Pasted_Image_16_10_2015__07_18.png


Either this code is half finished or you do not grasp the concept of the language, it is all Objective-C (except the C function CGVectorMake()).

I am around all day today, happy to help if you have more questions.

Cheers for the reply! I'm using Swift, I started coding recently, so I'm a total noob. I don't know what's best for creating games: Swift or Objective-c? I'm trying to make a flappy bird game and release it to the App Store. My mum bought me a 'how to code with spritekit' book, the language used in there is Objective-c. Shall I learn Swift or Objective-c? Which one's better? Thanks again.
 

DannyBres

macrumors 65816
Oct 30, 2007
1,412
6
UK
Cheers for the reply! I'm using Swift, I started coding recently, so I'm a total noob. I don't know what's best for creating games: Swift or Objective-c? I'm trying to make a flappy bird game and release it to the App Store. My mum bought me a 'how to code with spritekit' book, the language used in there is Objective-c. Shall I learn Swift or Objective-c? Which one's better? Thanks again.

If you book is in objective-c then you'll be best writing in objective -c, so you can follow along.

Is it this book: http://www.apress.com/9781430264392 ?

If so, it states it is for:
Beginning developers who have some understanding of object-oriented programming as well as intermediate iOS developers who want to get up to speed quickly with Sprite Kit.​

I'd suggest you work through, Objective-C Programming: The Big Nerd Ranch Guide (2nd Edition) and iOS Programming: The Big Nerd Ranch Guide (4th Edition) first.

You struggle so much jumping straight into SpriteKit, you really need to understand how Objective-C and the Cocoa Framework works first.

I would avoid Swift atm, as it is still in its infancy and there is much more literature for Objective-C available.
 

AlexTheXcodeProgrammer

macrumors newbie
Original poster
Oct 11, 2015
10
0
If you book is in objective-c then you'll be best writing in objective -c, so you can follow along.

Is it this book: http://www.apress.com/9781430264392 ?

If so, it states it is for:
Beginning developers who have some understanding of object-oriented programming as well as intermediate iOS developers who want to get up to speed quickly with Sprite Kit.​

I'd suggest you work through, Objective-C Programming: The Big Nerd Ranch Guide (2nd Edition) and iOS Programming: The Big Nerd Ranch Guide (4th Edition) first.

You struggle so much jumping straight into SpriteKit, you really need to understand how Objective-C and the Cocoa Framework works first.

I would avoid Swift atm, as it is still in its infancy and there is much more literature for Objective-C available.


Thanks for the advice. The game that I want to make is really hard for me to make. The boom that I've bought is the one woth a spaceship on the cover of the book(https://www.google.co.uk/shopping/p...cTHzMgCFQZMFAodw7YMWA&ei=pdgjVrzPFoaYUcPtssAF). Are there any free pdfs online which would enable to learn Objective-c fast(like in a month or so) Cheers
 

JWalker1995

macrumors regular
Mar 5, 2011
224
3
The game that I want to make is really hard for me to make.

Are there any free pdfs online which would enable to learn Objective-c fast(like in a month or so) Cheers

These two quotes scream failure. If your going to do something, you may as well do it properly. Gotta learn to walk before you can run. Find something that can teach you properly, and then when your ready attempt projects of increasing difficulty before your ready to have a go at your game. Rome wasn't built in a day! Happy to help if you want any advise, been a mobile developer for roughly a year now with a large UK company :)
 

AlexTheXcodeProgrammer

macrumors newbie
Original poster
Oct 11, 2015
10
0
These two quotes scream failure. If your going to do something, you may as well do it properly. Gotta learn to walk before you can run. Find something that can teach you properly, and then when your ready attempt projects of increasing difficulty before your ready to have a go at your game. Rome wasn't built in a day! Happy to help if you want any advise, been a mobile developer for roughly a year now with a large UK company :)
You surely do know how to motivate me! Thanks a lot, that has touched me a bit. Please can I jave some advice on how you started? I'm 15, and would love to take part of a compamy when I'm older. Thank you :)
 

JWalker1995

macrumors regular
Mar 5, 2011
224
3
You surely do know how to motivate me! Thanks a lot, that has touched me a bit. Please can I jave some advice on how you started? I'm 15, and would love to take part of a compamy when I'm older. Thank you :)
Hey,

Yeah I get it was a bit tough, but somebody said it to me ~3 years ago and it just motivated me further, I'm only 20 myself. Basically I did college (UK Mid school aged 16-18) where I studied computer programming as one of my 3 modules which gave me a good a basic grasp of programming basics, and then got a job at the company I work for as an iOS developer. Money isn't great atm but I have good careers prospects and there funding my part time degree

(Not sure how my work takes with identifying online so I'm going to err on the side of caution, but you'll have heard of it's US or UK segment :) )

PM me if you'd like to talk more :)

James
 

AlexTheXcodeProgrammer

macrumors newbie
Original poster
Oct 11, 2015
10
0
Hey,

Yeah I get it was a bit tough, but somebody said it to me ~3 years ago and it just motivated me further, I'm only 20 myself. Basically I did college (UK Mid school aged 16-18) where I studied computer programming as one of my 3 modules which gave me a good a basic grasp of programming basics, and then got a job at the company I work for as an iOS developer. Money isn't great atm but I have good careers prospects and there funding my part time degree

(Not sure how my work takes with identifying online so I'm going to err on the side of caution, but you'll have heard of it's US or UK segment :) )

PM me if you'd like to talk more :)

James

Thanks for all of that! I would like to know more, but for now I'm going to focus on objective-C. Right now I'm on holiday in a hot Spanish country, so I will learn a bit everyday. I would love to create games, and become like you, an iOS developper. Can we DM on Twitter or Instagram? Thank you

Also, I'm focusing on a game like Mario Bros. put you can fire weapons. Do you know the code to fire weapons because I can't find any tutorials, cheers!
 

JWalker1995

macrumors regular
Mar 5, 2011
224
3
Hey, feel free to PM me on here :)

Your question about firing guns, again way to high level for someone new to programming. Tbh I've never created a a game or looked into metal/ any game engines so I'm not the best person to ask unfortunatly
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.