Assignment makes pointer from integer without a cast

Discussion in 'iOS Programming' started by Xcode Beginner, Jun 28, 2010.

  1. Xcode Beginner macrumors newbie

    Joined:
    Apr 28, 2010
    #1
    Can anyone tell me how to deal with this issue. I getting the messages:
    1) "Assignment makes pointer from integer without casting"
    2) "comparison between pointer and integer"


    The code runs and builds however I get these two messages with the Yellow flag.

    Please see the code below. I new at this so your help will appreciated.

    Code:
    #import "MainViewController.h"
    
    
    @implementation MainViewController
    
    
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
        if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
           [COLOR="SeaGreen"] // Custom initialization[/COLOR]
        }
        return self;
    }
    
    
    /*
    [COLOR="SeaGreen"]// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.[/COLOR]
    
    - (void)viewDidLoad {
    	[super viewDidLoad];
    }
    */
    
    
    - (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller {
        
    	[self dismissModalViewControllerAnimated:YES];
    }
    
    -(IBAction)displayMessage:(id)sender
    
    {
    	NSString *messageString = [[NSUserDefaults standardUserDefaults] stringForKey:@"kMessageString"];
    
    	
    	[messageLabel setText:messageString];
    		
    }
    	
    - (IBAction)showInfo {    
    	
    	FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil];
    	controller.delegate = self;
    	
    	controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    	[self presentModalViewController:controller animated:YES];
    	
    	[controller release];
    }
    
    
    - (void)didReceiveMemoryWarning {
    	[COLOR="SeaGreen"]// Releases the view if it doesn't have a superview.[/COLOR]
        [super didReceiveMemoryWarning];
    	
    	[COLOR="SeaGreen"]// Release any cached data, images, etc. that aren't in use.[/COLOR]
    }
    
    
    - (void)viewDidUnload {
    	[COLOR="SeaGreen"]// Release any retained subviews of the main view.
    	// e.g. self.myOutlet = nil;[/COLOR]
    }
    
    
    /*
    [COLOR="SeaGreen"]// Override to allow orientations other than the default portrait orientation.[/COLOR]
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    	[COLOR="SeaGreen"]// Return YES for supported orientations.[/COLOR]
    	return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
    */
    
    
    
    - (void)dealloc {
    	[messageLabel release];
        [super dealloc];
    }
    
    [COLOR="SeaGreen"]//------------------------------------------------------
    //Adding Nested Subviews[/COLOR].
    
    -(void)loadView
    
    {
    [COLOR="SeaGreen"]//create main view[/COLOR]
    
    	CGRect appRect = [[UIScreen mainScreen] applicationFrame];
    	
    	UIView *contentView = [[UIView alloc] initWithFrame:appRect];
    	contentView.backgroundColor = [UIColor whiteColor];
    	
    [COLOR="SeaGreen"]//Provide support for autorotation and resizing[/COLOR]
    	
    	contentView.autoresizesSubviews = YES;
    	contentView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
    	self.view = contentView;
    	[contentView release];
    	
    [COLOR="SeaGreen"]//Reset the origin point for the subviews.  The new origin is 0,0.[/COLOR]
    	
    	appRect.origin = CGPointMake(0.0f, 0.0f);
    	
    [COLOR="SeaGreen"]//Add the subviews, each stepped by 32 pixels on each side.[/COLOR]
    	
    	UIView *subview = [[UIView alloc] initWithFrame:CGRectInset(appRect, 32.0f, 32.0f)];
    	subview.backgroundColor = [UIColor lightGrayColor];
    	[contentView addSubview:subview];
    	[subview release];
    	
    	subview = [[UIView alloc] initWithFrame:CGRectInset(appRect, 64.0f, 64.0f)];
    	subview.backgroundColor = [UIColor blackColor];
    	[contentView addSubview:subview];
    	[subview release];
    	
    	subview = [[UIView alloc] initWithFrame:CGRectInset(appRect, 96.0f, 96.0f)];
    	subview.backgroundColor = [UIColor blackColor];
    	[contentView addSubview:subview];
    	[subview release];
    }
    
    [COLOR="SeaGreen"]//---------------------------------------------------------
    // Adding Reorientation Support to the Subviews.[/COLOR]
    
    -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
    
    {
    	CGRect apprect;
    	apprect.origin = CGPointMake(0.0f, 0.0f);
    	
    	[COLOR="SeaGreen"]//Adjust the frame size based on actual orientation.[/COLOR]
    	
    	UIView *orientation;
    	if ((orientation = UIInterfaceOrientationLandscapeLeft) || (orientation == UIInterfaceOrientationLandscapeRight))
    		apprect.size = CGSizeMake(480.0f, 300.0f);
    
    [COLOR="Red"]This is where I have the messages after running and building.[/COLOR]:
    [COLOR="Red"]1) "Assignment makes pointer from integer without casting"
    2) "comparison between pointer and integer"[/COLOR]	
    	else 
    		apprect.size = CGSizeMake(320.0f, 460.0f);
    	 
    	[COLOR="SeaGreen"]//Resize each subview accordingly.[/COLOR]
    	
    	float offset = 32.0f;
    	UIView *contentView;
    	for (UIView *subview in [contentView subviews]) 
    	
    	{
    		CGRect frame = CGRectInset(apprect, offset, offset);
    		[subview setFrame:frame];
    		offset = 32.0f;
    	}
    	
    	}
    [COLOR="SeaGreen"]//Allow orientation change with Iphone orientation.[/COLOR]
    
    -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
    
    {
    	return YES;
    }
    
    @end
     
  2. ritsard macrumors regular

    ritsard

    Joined:
    Jun 18, 2009
    Location:
    SF Bay Area, CA
    #2
    Code:
    	if ((orientation = UIInterfaceOrientationLandscapeLeft) || (orientation == UIInterfaceOrientationLandscapeRight))
    		apprect.size = CGSizeMake(480.0f, 300.0f);
    
    I think the problem is in here where you set the orientation. It looks like you have a typo for the test if orientation is equal to UIInterfaceOrientationLandscapeLeft. You probably missed one equals "=" sign.

    Code:
    	if ((orientation == UIInterfaceOrientationLandscapeLeft) || (orientation == UIInterfaceOrientationLandscapeRight))
    		apprect.size = CGSizeMake(480.0f, 300.0f);
    
     

Share This Page