'Expected Declaration' Error

Discussion in 'iOS Programming' started by AlexTheXcodeProgrammer, Oct 11, 2015.

?

Does anyone know how to fix this error?

This poll will close on Apr 11, 2023 at 1:35 PM.
  1. Yes ;) I'll help

    1 vote(s)
    100.0%
  2. No Sorry I don't know ;(

    0 vote(s)
    0.0%
Multiple votes are allowed.
  1. AlexTheXcodeProgrammer macrumors newbie

    Joined:
    Oct 11, 2015
    #1
    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! :)
     

    Attached Files:

  2. JWalker1995 macrumors regular

    Joined:
    Mar 5, 2011
    #2
    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 :)
     
  3. AlexTheXcodeProgrammer, Oct 12, 2015
    Last edited by a moderator: Oct 12, 2015

    AlexTheXcodeProgrammer thread starter macrumors newbie

    Joined:
    Oct 11, 2015
    #3

    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 :(
     
  4. mfram macrumors 65816

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #4
    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?
     
  5. AlexTheXcodeProgrammer thread starter macrumors newbie

    Joined:
    Oct 11, 2015
    #5

    I'm intending to use SpriteKit
     
  6. DannyBres macrumors 65816

    DannyBres

    Joined:
    Oct 30, 2007
    Location:
    UK
    #6
    That isn't a language. You need to pick Objective-C or Swift for Xcode development.

    [​IMG]

    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.
     
  7. AlexTheXcodeProgrammer thread starter macrumors newbie

    Joined:
    Oct 11, 2015
    #7
    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.
     
  8. DannyBres macrumors 65816

    DannyBres

    Joined:
    Oct 30, 2007
    Location:
    UK
    #8
    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.
     
  9. AlexTheXcodeProgrammer thread starter macrumors newbie

    Joined:
    Oct 11, 2015
    #9

    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
     
  10. JWalker1995 macrumors regular

    Joined:
    Mar 5, 2011
    #10
    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 :)
     
  11. AlexTheXcodeProgrammer thread starter macrumors newbie

    Joined:
    Oct 11, 2015
    #11
    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 :)
     
  12. JWalker1995 macrumors regular

    Joined:
    Mar 5, 2011
    #12
    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
     
  13. AlexTheXcodeProgrammer thread starter macrumors newbie

    Joined:
    Oct 11, 2015
    #13
    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!
     
  14. JWalker1995 macrumors regular

    Joined:
    Mar 5, 2011
    #14
    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
     
  15. AlexTheXcodeProgrammer thread starter macrumors newbie

    Joined:
    Oct 11, 2015
    #15
    Ok, thank you
     

Share This Page