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

stadidas

macrumors regular
Original poster
Feb 27, 2006
243
0
Kent, United Kingdom
I've been teaching myself Objective C over the last few days using this Wikibook.
I keep getting errors on the WKDDrawView class (which I've called SDDrawView) and I can't think how to fix them.

SDDrawErrors.png


I've uploaded my attempt here. if anyone can give me any help I'd greatly appreciate it.
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,629
Western US
1. kHandleSize doesn't seem to be declared anywhere.

2. Looks like you never give _dragShape a type. Maybe you just want it untyped as id or a specific type like SDShape or something but it needs to have one:

SDShape *_dragShape = ...

or id _dragShape = ...

(but I can't see your .h files)

...and so on. Basically, the compiler seems to be telling you the right things here generally, pay attention to what it says and go fix it line by line. Variables need to be declared in advance (either locally or in a .h file if instance variables). When you get argument warnings like that, look up the function or method in the Apple docs and check your argument types against the reference.

It looks like you are in fact giving NSIntersectsRect an NSRect as the second arg (which is correct). In this case, the compiler might be complaining about other errors down the line and coming up with phantom errors at the top. It's a bit wonky and does that sometimes, so sometimes you need to skip down and start fixing lower errors and the top ones will magically go away.
 

stadidas

macrumors regular
Original poster
Feb 27, 2006
243
0
Kent, United Kingdom
I've uploaded the .h file here.

I think you're right about the phantom errors. It also says that the Switch quantity given is not an integer, even though in it's parameter I give it a method which returns an integer.
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,629
Western US
So yeah it looks like you do need to declare a type for _dragShape somewhere. I don't see that in your .h file or in the local methods you use it in. Sometimes the compiler will come out with 24 errors and you fix one forgotten semicolon or brace and it compiles, it takes a while to figure out what it's really trying to tell you. If the errors just don't make sense, start suspecting something else.
 

stadidas

macrumors regular
Original poster
Feb 27, 2006
243
0
Kent, United Kingdom
Thanks for your help. I understand what's wrong, but can't fix it as I don't know what to declare _dragshape as. The author of the Wikibook doesn't make it very clear. I'll have to wait for it to be updated.
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,629
Western US
Looks like you'd want to declare it as an SDShape*, or possibly untyped as an id. But if that part doesn't work, very likely there's other stuff wrong too.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.