Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-14-2011, 07:28 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 139
sumosumo84 is on a distinguished road
Default property problems

hi, i am new to properties and never knew their capabilities untill now.

Unfortunatly i cannot harness their capabilities as i am having an error.

Here is my code:

Code:
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
    ball = [Ball alloc];
    ball.position = CGPointMake(100.0, 100.0);
    ball.velocity = CGPointMake(4.0, 3.0);
    
}
(object ball was made in the .h)
(the errors are happening on ball.position, and ball.velocity.)

Ball.h:
Code:
@interface Ball : NSObject {
    CGPoint *position;
    CGPoint *velocity;
    CGFloat *radius;
    CGColorRef *color;
    
}

@property(nonatomic) CGPoint *position;
@property(nonatomic) CGPoint *velocity;
@property(nonatomic) CGFloat *radius;
@property(nonatomic) CGColorRef *color;
no errors here, but there is probably a problem causing the error.

The error is:
Code:
Assigning to 'CGPoint *' (aka 'struct CGPoint *') from incompatible type 'CGPoint' (aka 'struct CGPoint')
Looking at the error message, i am guessing it has something to do with having one CGPoint be a pointer, and the other not being a pointer. I am not for sure and don't want to screw anything up.

Thanks for your help!

-SumoSumo Apps
sumosumo84 is offline   Reply With Quote
Old 03-14-2011, 07:43 PM   #2 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 577
Speed is on a distinguished road
Default

Try remove the asterisk from CGPoint *point; (ie. make it CGPoint point;
Speed is offline   Reply With Quote
Old 03-14-2011, 07:46 PM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 139
sumosumo84 is on a distinguished road
Default

Quote:
Originally Posted by Speed View Post
Try remove the asterisk from CGPoint *point; (ie. make it CGPoint point;
k ill try
sumosumo84 is offline   Reply With Quote
Old 03-14-2011, 07:46 PM   #4 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

See the properties link in my signature for guidance.

Additionally:

Code:
ball = [Ball alloc];
1. This doesn't use the property
2. You can pretty much assume that alloc should always be followed by init

Code:
@interface Ball : NSObject {
    CGPoint *position;
    CGPoint *velocity;
    CGFloat *radius;
    CGColorRef *color;
}

@property(nonatomic) CGPoint *position;
@property(nonatomic) CGPoint *velocity;
@property(nonatomic) CGFloat *radius;
@property(nonatomic) CGColorRef *color;
There will be exceptions, but for the most part you can assume that * is used on objects, and is not used on non-objects (ints, floats, etc). None of these items are objects, so no *.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 03-14-2011, 07:51 PM   #5 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 139
sumosumo84 is on a distinguished road
Default

it works, wow i feel stupid.
Thanks!
sumosumo84 is offline   Reply With Quote
Reply

Bookmarks

Tags
error, properties, property

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
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 364
11 members and 353 guests
Absentia, akphyo, apatsufas, BinHex, blueorb, fredidf, iGamesDev, Kirkout, MarkC, mottdog, Touchmint
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:26 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0