Amazon.com Widgets warning in program 8.3
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 30, 2014, 10:57:56 PM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Programming in Objective-C, 4th edition
| |-+ Chapter 8
| | |-+ warning in program 8.3
Pages: [1] Go Down
Print
Author Topic: warning in program 8.3 (Read 580 times)
eagle74
Newbie
*
Posts: 24


www.cucinareblog.it


WWW Email




on: April 26, 2012, 06:32:06 AM

Hy everybody, I am studying Obj-c on this really good book!
Now I have a little problem, in program 8.3 I receive this warning:
"writable atomic property 'side' cannot pair a synthesized setter with a used defined getter"
Is it normal, or have I written something wrong?
Maybe the code in squares.m :
-(int) side
{
    return self.width;
}

is superfluous because I already have synthesized the side variable?

My source code:

Squares.h:
#import <Foundation/Foundation.h>
#import "Rectangles.h"

@interface Squares : Rectangles

@property int side;

-(void) setSideSquare: (int) s;
-(int) side;

@end

Squares.m

#import "Squares.h"
@implementation Squares


@synthesize side;

-(void) setSideSquare: (int) s
{  
    
    [self setWidth: s andHeight: s];
    side=s;
}

-(int) side //here is the warning
{
    return self.width;
}

@end

main:

#import <Foundation/Foundation.h>
#import "Rectangles.h"
#import "Squares.h"


int main(int argc, const char * argv[])
{

    @autoreleasepool {
   /*    
    Rectangles *R1=[[Rectangles alloc]init];
        
    [R1 setWidth: 5 andHeight: 8];
    NSLog(@"Rettangolo di base %i e altezza %i", R1.width, R1.height);
    NSLog(@"L'area : %i e il perimetro : %i", [R1 area], [R1 perimeter]);
        */
        Squares *S1=[[Squares alloc]init];
        [S1 setSideSquare: 4];
        NSLog(@"Quadrato di lato %i",[S1 side] );
        NSLog(@"L'area : %i e il perimetro : %i", [S1 area ], [S1 perimeter]);
        
    }
    return 0;
}

Last Edit: April 26, 2012, 07:59:35 AM by eagle74 Logged

"The more i know people the more i love dogs."Socrate
rue
Jr. Member
**
Posts: 53






Reply #1 on: April 26, 2012, 09:57:47 AM

You already @property and @synthesize side, so you don't need to define the actual method for it.  You can delete your method and let Xcode create the setter/getter for you.
Logged
eagle74
Newbie
*
Posts: 24


www.cucinareblog.it


WWW Email




Reply #2 on: April 27, 2012, 10:11:19 AM

ok thanks a lot!  Wink
Logged

"The more i know people the more i love dogs."Socrate
Pages: [1] Go Up
Print
Jump to:



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.