example:
Code:NSString *path = @"~"; path = [path stringByExpandingTildeInPath];
Ah that makes more sense. And it works! Thanks
example:
Code:NSString *path = @"~"; path = [path stringByExpandingTildeInPath];
Why haven't they posted Wednesday's class yet?![]()
Yeah, what's the deal? On the course site they have a link for Lecture 5, but when it comes up in iTunes it only shows the PDF for that one, no video. Oddly, if I try to get to the course through the iTunes store rather than that one link, it only shows PDFs 1-4.. the heck?
With the same PolygonShape I used this for the Controller implementation of 2b:
Code:#import "Controller.h" #import "PolygonShape.h" @implementation Controller - (void) updateInterface { numberOfSidesLabel.text = [NSString stringWithFormat:@"%d",polygon.numberOfSides]; } - (IBAction)decrease:(id)sender { NSLog(@"decreasing"); --polygon.numberOfSides; if (polygon.numberOfSides == polygon.minimumNumberOfSides) decreaseButton.enabled = NO; increaseButton.enabled = YES; [self updateInterface]; } - (IBAction)increase:(id)sender { NSLog(@"increasing"); ++polygon.numberOfSides; if (polygon.numberOfSides == polygon.maximumNumberOfSides) increaseButton.enabled = NO; decreaseButton.enabled = YES; [self updateInterface]; } - (void) awakeFromNib { polygon = [[PolygonShape alloc] initWithNumberOfSides:5 minimumNumberOfSides:3 maximumNumberOfSides:12]; NSLog(@"My polygon: %@", polygon); [self updateInterface]; } @end
polygon should be dealloced, I know... Will happen.
also checks before in/de creasing the num of sides would be better as in the future other things might influence the side count.
Oh well...
Hmmm maybe I should go for
Code:[polygon setNumberOfSides:polygon.numberOfSides[+-]1]
Is the accessor called when I use the ++ / -- operands ?
[edit]
Ah, it is... sweet.
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "PolygonShape.h"
@interface Controller : NSObject {
IBOutlet UIButton *decreaseButton;
IBOutlet UIButton *increaseButton;
IBOutlet UILabel *numberOfSidesLabel;
IBOutlet PolygonShape *aPolygon;
}
- (IBAction)decrease;
- (IBAction)increase;
@property (nonatomic, retain) UIButton *decreaseButton;
@property (nonatomic, retain) UIButton *increaseButton;
@property (nonatomic, retain) UILabel *numberOfSidesLabel;
@property (nonatomic, retain) PolygonShape *aPolygon;
@end
#import "Controller.h"
@implementation Controller
@synthesize numberOfSidesLabel;
@synthesize increaseButton;
@synthesize decreaseButton;
@synthesize aPolygon;
- (IBAction)decrease
{
--aPolygon.numberOfSides;
[self updateInterface];
}
- (IBAction)increase
{
++aPolygon.numberOfSides;
[self updateInterface];
}
-(void)awakeFromNib
{
aPolygon = [[PolygonShape alloc] initWithNumberOfSides:numberOfSidesLabel.text.integerValue minimumNumberOfSides:3 maximumNumberOfSides:12];
NSLog(@"My polygon: %@", [aPolygon polyDescription]);
}
-(void)updateInterface
{
numberOfSidesLabel.text = [NSString stringWithFormat:@"%d", [aPolygon numberOfSides]];
if (aPolygon.numberOfSides == aPolygon.minimumNumberOfSides)
{
decreaseButton.enabled = NO;
}
else
{
decreaseButton.enabled = YES;
}
if (aPolygon.numberOfSides == aPolygon.maximumNumberOfSides)
{
increaseButton.enabled = NO;
}
else
{
increaseButton.enabled = YES;
}
}
@end
Hi simonjfrancis,
I found that I had to put the full path to my PolygonShape.h file, such as:
#import </Users/Tom/Documents/Assignment 2/PolygonShape.h>
I don't know why - it was in the same directory as my other source files. But anyway that might help.
Tom
@simon: Here is my code thus far:
First is Controller.h
Code:#import <UIKit/UIKit.h> #import <Foundation/Foundation.h> #import "PolygonShape.h" @interface Controller : NSObject { IBOutlet UIButton *decreaseButton; IBOutlet UIButton *increaseButton; IBOutlet UILabel *numberOfSidesLabel; IBOutlet PolygonShape *aPolygon; } - (IBAction)decrease; - (IBAction)increase; @property (nonatomic, retain) UIButton *decreaseButton; @property (nonatomic, retain) UIButton *increaseButton; @property (nonatomic, retain) UILabel *numberOfSidesLabel; @property (nonatomic, retain) PolygonShape *aPolygon; @end
Here is Controller.m:
Code:#import "Controller.h" @implementation Controller @synthesize numberOfSidesLabel; @synthesize increaseButton; @synthesize decreaseButton; @synthesize aPolygon; - (IBAction)decrease { --aPolygon.numberOfSides; [self updateInterface]; } - (IBAction)increase { ++aPolygon.numberOfSides; [self updateInterface]; } -(void)awakeFromNib { aPolygon = [[PolygonShape alloc] initWithNumberOfSides:numberOfSidesLabel.text.integerValue minimumNumberOfSides:3 maximumNumberOfSides:12]; NSLog(@"My polygon: %@", [aPolygon polyDescription]); } -(void)updateInterface { numberOfSidesLabel.text = [NSString stringWithFormat:@"%d", [aPolygon numberOfSides]]; if (aPolygon.numberOfSides == aPolygon.minimumNumberOfSides) { decreaseButton.enabled = NO; } else { decreaseButton.enabled = YES; } if (aPolygon.numberOfSides == aPolygon.maximumNumberOfSides) { increaseButton.enabled = NO; } else { increaseButton.enabled = YES; } } @end
@ChOas:
Thanks very much for that, I didn't really know about the " versus the <> thing![]()
Isn't it just "esc" key, which is much easier to push?
How about reading a book, "Beginning iPhone Development" would have taken you further and deeper into most subjects they have discussed in class. The class should only be used as reference, not the main learning source. I am falling asleep through these lectures.I can personally vouch for this course. I knew almost next to nothing about how to begin programming an app and after spending a lot of time with this course I'm about halfway done with my first app now.
Googling around for tutorials wasn't helping -- I needed a structured approach to learning Obj C and for me this class was a huge help.
int sideToDraw = [aPolygonShape numberOfSides]