Hi all,
I am extremely new to iPhone development and I was assigned the 'easy' task of creating a pulsating color background. Basically, I need the screen to pulsate different colors. I understand the logic behind it - I need a timer that changes the color every second, and I need to generate random colors to assign the background to. This is what I have so far..
UIColorRandom.h
UIColorRandom.m
ColorPulseViewController.m
I don't get any error/warning messages during the build but it continues to crash.. this is the message that I get in the debugger window.
2010-10-04 14:23:45.976 ColorPulse[15819:207] ******* Accessibility Status Changed: On
2010-10-04 14:23:46.001 ColorPulse[15819:207] ********** Loading AX for: com.yourcompany.ColorPulse ************
2010-10-04 14:23:47.046 ColorPulse[15819:207] *** NSInvocation: warning: object 0x30a0 of class 'UIColorRandom' does not implement methodSignatureForSelector: -- trouble ahead
2010-10-04 14:23:47.047 ColorPulse[15819:207] *** NSInvocation: warning: object 0x30a0 of class 'UIColorRandom' does not implement doesNotRecognizeSelector: -- abort
I am extremely new to this.. and by new I mean I have just been introduced to this for less than a week now and I am suppose to learn this on my own. I have been doing all the tutorials but I can't seem to understand what is going on. I know this is a really easy task and that is why I am extremely frustrated I can't get it to work. Any help is greatly appreciated! Thanks !
I am extremely new to iPhone development and I was assigned the 'easy' task of creating a pulsating color background. Basically, I need the screen to pulsate different colors. I understand the logic behind it - I need a timer that changes the color every second, and I need to generate random colors to assign the background to. This is what I have so far..
UIColorRandom.h
Code:
#import <Foundation/Foundation.h>
#import <UIKit/UIkit.h>
@interface UIColorRandom {
}
+(UIColor *)randomColor;
@end
Code:
#import "UIColorRandom.h"
@implementation UIColorRandom
+(UIColor *)randomColor
{
static BOOL seeded = NO; // tells us if it is the first time through this method
if (!seeded) { // after seeding has been done
seeded = YES; // seeded will change to YES so that it states it is not the first time
srandom(time(NULL));
}
{
// generate random floats for rgb to make random colors values from 0.0 - 1.0
CGFloat red = (CGFloat)random()/(CGFloat)RAND_MAX;
CGFloat blue = (CGFloat)random()/(CGFloat)RAND_MAX;
CGFloat green = (CGFloat)random()/(CGFloat)RAND_MAX;
return[UIColor colorWithRed:red green:green blue:blue alpha:1.0];
}
}
@end
Code:
#import "ColorPulseViewController.h"
#import "UIColorRandom.h"
@implementation ColorPulseViewController
-(void)loadView
{
[NSTimer scheduledTimerWithTimeInterval:1
target:self
selector:@selector(pulseColor)
userInfo:nil
repeats:YES];
}
-(void)pulseColor
{
UIColor *randColor = [UIColorRandom randomColor];
self.view.backgroundColor = randColor;
}
2010-10-04 14:23:45.976 ColorPulse[15819:207] ******* Accessibility Status Changed: On
2010-10-04 14:23:46.001 ColorPulse[15819:207] ********** Loading AX for: com.yourcompany.ColorPulse ************
2010-10-04 14:23:47.046 ColorPulse[15819:207] *** NSInvocation: warning: object 0x30a0 of class 'UIColorRandom' does not implement methodSignatureForSelector: -- trouble ahead
2010-10-04 14:23:47.047 ColorPulse[15819:207] *** NSInvocation: warning: object 0x30a0 of class 'UIColorRandom' does not implement doesNotRecognizeSelector: -- abort
I am extremely new to this.. and by new I mean I have just been introduced to this for less than a week now and I am suppose to learn this on my own. I have been doing all the tutorials but I can't seem to understand what is going on. I know this is a really easy task and that is why I am extremely frustrated I can't get it to work. Any help is greatly appreciated! Thanks !