Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
anyone else having trouble downloading lecture 2 and the related slides?

No, but you're not missing much on this one...Lecture #2 had a different presenter than the first lecture, and he seemed totally unprepared. If I was paying money to go to Stanford I would be pissed that this was the quality I was getting.

Just my two cents' worth.
 
No, but you're not missing much on this one...Lecture #2 had a different presenter than the first lecture, and he seemed totally unprepared. If I was paying money to go to Stanford I would be pissed that this was the quality I was getting.

Just my two cents' worth.
I agreed. It was definitely one of the lectures that could be better invested doing something else like napping.
 
any one want to compare assignments?

any one want to compare assignments? i have a little problem ...i need help..thanks
 
No, but you're not missing much on this one...Lecture #2 had a different presenter than the first lecture, and he seemed totally unprepared. If I was paying money to go to Stanford I would be pissed that this was the quality I was getting.

Just my two cents' worth.

I am so glad you wrote this because this is exactly how I feel too. The presentation for lecture 2 was dire and yes he was totally unprepared!

I was screaming at my screen at how he was making it up as he went along!

As you say if I had paid for that lecture I would be asking for a refund.

I hope the rest are better otherwise I wont bother with them!
 
I am watching the courses even though I am in way over my head. I need to learn C first (don't know anything) ( see this thread https://forums.macrumors.com/threads/680658/ ), but I figure like learning a foreign language it doesn't hurt to watch even though I really have no idea wth they are talking about--it might sink in by osmosis. :rolleyes:

I'm in the same boat. I've been following along with the lectures and attempting the assignments. I'm for sure in way over my head. Despite having taken a class (and getting an 'A') on basic C programming in college, I don't have a great grasp on interacting with a programming language. One of the hardest parts for me is that a lot of the terminology is over my head. I think I can pick up the language, syntax, etc. but I find myself googling a lot of the words they're using. Oh well...

I also think rush0's idea of a google group or something of the sort would be pretty helpful. I tend to learn by following examples, so maybe some of you smart folks could help us slower ones along. :)
 
Well, I just started downloading the videos off iTunes. I also am downloading the PDFs. So hopefully this is relatively easy for me. :rolleyes: I know C++ (I got a C in the class cause I was lazy and didn't do the homework most of the time, just took it last semester. Easy transition from Java, just had to learn keywords), Java (I got a 100 in the class but I took it my junior year in high school), HTML and taught myself some PHP. Anyone know that it'll be easy or hard for me?

EDIT: Btw, I think if you get real bad problems, use iChat and take over the computer and show 'em what you are doing to their project to help 'em out.
 
I certainly would not base this content on a way to learn iPhone programming as am now in lecture 3 and am less than impressed.

Interesting to watch, but to learn a great deal from I don't think so.
 
someone can upload the solutions for 2b and 2b ?

someone can upload the solutions for 2b and 2b that we can compare?
 
someone can upload the solutions for 2b and 2b that we can compare?

I'm just getting started with this course and this is my implementation for PolygonShape (2a). Still needs some optimising and errorchecking but hey:


Code:
#import "PolygonShape.h"


@implementation PolygonShape

@synthesize numberOfSides, minimumNumberOfSides, maximumNumberOfSides, name;

- (void) setNumberOfSides:(int) numSides {
	if (numSides > maximumNumberOfSides) {
		NSLog(@"Invalid number of sides: %d is greater than the maximum of %d allowed",numSides, maximumNumberOfSides);
		return;
	} 
	if (numSides < minimumNumberOfSides) {
		
		NSLog(@"Invalid number of sides: %d is less than the minimmum of %d allowed",numSides, minimumNumberOfSides);
		return;
	}
	numberOfSides = numSides;
}

- (void) setMinimumNumberOfSides:(int) newMin {
	if (newMin < 2) {
		NSLog(@"Invalid number of minimum sides, %d is less than 2", newMin);
		return;
	}
	minimumNumberOfSides = newMin;
}

- (void) setMaximumNumberOfSides:(int) newMax {
	if (newMax > 12) {
		NSLog(@"Invalid number of maximum sides, %d is more than 2", newMax);
		return;
	}
	maximumNumberOfSides = newMax;
}

- (id) initWithNumberOfSides: (int) numSides minimumNumberOfSides:(int) minSides maximumNumberOfSides:(int) maxSides {
	[self setMinimumNumberOfSides:minSides];
	[self setMaximumNumberOfSides:maxSides];
	[self setNumberOfSides:numSides];
	NSLog([self description]);
	return self;
};

- (id) init {
	return self = [[PolygonShape alloc] initWithNumberOfSides:5 minimumNumberOfSides:3 maximumNumberOfSides:10];
};

- (NSString *) description {
	
	float degAngle = (float) (180 * (float) (numberOfSides-2) / numberOfSides);
	float radAngle = (float) degAngle/180 * M_PI;
	NSArray *polyName = [NSArray arrayWithObjects:	@"triangle", @"square",   @"pentagon", @"hexagon",    @"heptagon",
													@"octagon" , @"enneagon", @"decagon",  @"hendecagon", @"dodecagon", nil];
	
	return [NSString stringWithFormat:@"Hello, I am a %d-sided polygon (aka a %@) with angles of %0.0f degrees (%f radians).",
			numberOfSides, [polyName objectAtIndex: (numberOfSides-3)], degAngle, radAngle];
}
   
- (void) dealloc {
	[super dealloc];
	NSLog(@"A poly just died");
};
@end
 
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.
 
Code:
- (NSString *) description {
	
	float degAngle = (float) (180 * (float) (numberOfSides-2) / numberOfSides);
	float radAngle = (float) degAngle/180 * M_PI;
	NSArray *polyName = [NSArray arrayWithObjects:	@"triangle", @"square",   @"pentagon", @"hexagon",    @"heptagon",
													@"octagon" , @"enneagon", @"decagon",  @"hendecagon", @"dodecagon", nil];
	
	return [NSString stringWithFormat:@"Hello, I am a %d-sided polygon (aka a %@) with angles of %0.0f degrees (%f radians).",
			numberOfSides, [polyName objectAtIndex: (numberOfSides-3)], degAngle, radAngle];
}

Chaos,
I'm curious, did you make angle and radians read only properties? I think that was specified in the assignment. Aka
Code:
@property (readonly) float angleInDegrees;
@property (readonly) float angleInRadians;

And then implement methods for them.

Also, just a slight critique on the use of 'return'. It's much cleaner and easier to read/follow the code if you use :

if
{

}
else
{

}

rather than returning from within the 'if'. Just my $0.02.
 
Hi Steve,

1: Good one, dunno why I actually follow that through, mind must have been wandering off :)

2: The return statements in the ifs is a Perl habit I happen to have :)

Thanks for commenting, will update my class
 
Hi Steve,

1: Good one, dunno why I actually follow that through, mind must have been wandering off :)

2: The return statements in the ifs is a Perl habit I happen to have :)

Thanks for commenting, will update my class

Yeah, it's not really a big deal, I'm used to working in teams, easy to read and 'clean' become a factor.... It's functional either way.
 
Yeah, it's not really a big deal, I'm used to working in teams, easy to read and 'clean' become a factor.... It's functional either way.

Bugs me too to be honest, call me fussy but I've also got a deep hatred for if's without braces e.g:-

Code:
if(condition == true)
    DoSomething;

Its horrible! (even if it is a single line, and its even more annoying when its followed by an else!)

Code:
if(condition == true)
{
    DoSomething;
}
The above doesn't kill and to be honest it is much more readable! God knows how the hell not using the braces was ever accepted as a standard
 
Ya, writing horrible looking codes is as bad as writing non-working codes in most cases, unless of course, you're a one-man team and you simply don't care.
 
retarded question

Hi everyone,

I'm having a real problem just itterating through the array and printing out the objects' className. Here is what I have so far:

Code:
void PrintIntrospectionInfo() {
	
	NSMutableArray *myObjects;
	myObjects = [[NSMutableArray alloc] init];
	NSString *myString = @"bob";
	NSMutableString *myMutableString = @"floyd";
	NSURL *myURLs = [NSURL URLWithString:@"http://google.com.au"];
	NSDictionary *myDictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"happy", @"smile", @"sad", @"frown"];
	NSString *myProcessName = [[NSProcessInfo processInfo] processName];
	
	[myObjects addObject:myString]; //there has got to be a better way to do this
	[myObjects addObject:myMutableString];
	[myObjects addObject:myURLs];
	[myObjects addObject:myDictionary];
	[myObjects addObject:myProcessName];
	
	
	for (id obj in myObjects) {
		NSLog(@"Class Name: %@", [obj className]);
		
	}

}

Any ideas?

EDIT: I should mention the problem I guess :) = nothing prints out in the console at all.
 
I'm having some trouble with assignment 1B...here's my code for section 1:

Code:
void PrintPathInfo() {

	NSString *path = @"~";
	
	NSArray *array = [path pathComponents];
	NSLog(@"%@",
		  [array componentsJoinedByString:@"/"]);
	
	
}

I can't figure out how to expand the "~" into the actual path, any suggestions?
 
I think you should check out the stringByExpandingTildeInPath method. It's handy for doing the expansion.
 
I think you should check out the stringByExpandingTildeInPath method. It's handy for doing the expansion.

I don't quite understand how the syntax works, can someone explain?

From Apple's documentation:
Code:
- (NSString *)stringByExpandingTildeInPath

I don't get how to pass the string from my above code to this line...
Also, I understand that a * indicates a pointer when used as in *variable, what does the * indicate here?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.