Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

TechnoEagle

macrumors newbie
Original poster
Jan 30, 2010
17
0
I have just started trying to learn how to develop iPhone/iPad apps. I have been using the Stanford lecture videos on iTunes U, and have learned a lot so far. I did come across a problem while doing homework assignment 1B. I can't seem to figure out how to get it to work. Has anyone either watched these videos, or just knows a lot about Objective-C? If someone could post the code for the assignment so that I can figure out what I was doing wrong, that would be great! The homework assignment can be found at http://cs193p.stanford.edu As I said before, it is assignment 1B that I cannot figure out.
Thanks in advance! :D
 
Here is my code for the implementation file:

Code:
#import <Foundation/Foundation.h>
void PrintPathInfo()
{
	NSString *path=[@"~" stringByExpandingTildeInPath];
	NSLog(path);
}
void PrintProcessInfo()
{
	NSString *infoAboutProcess=@"Process Name: ";
	infoAboutProcess=[infoAboutProcess stringByAppendingFormat:[[NSProcessInfo processInfo] processName]];
	infoAboutProcess=[infoAboutProcess stringByAppendingFormat:@" Process ID: "];
	infoAboutProcess=[infoAboutProcess stringByAppendingFormat:[NSProcessInfo processInfo]];
	NSLog(infoAboutProcess);
}
void PrintBookmarkInfo()
{
	
}
void PrintIntrospectionInfo()
{
	
}
int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    PrintPathInfo();
	PrintProcessInfo();
	PrintBookmarkInfo();
	PrintIntrospectionInfo();
	
	[pool release];
    return 0;
}

For the PrintPathInfo() method, I cannot figure out how to separate each part of the path directory onto a separate line. For the PrintProcessInfo(), I keep getting weird errors and cannot figure out what to do. I haven't even started to work on the PrintBookmarkInfo() and PrintIntrospectionInfo() yet, because I want to get the first two methods working, first.
 
NSArray *pathComponents = [[NSArray alloc] init];
pathComponents = [path pathComponents];

for (NSString *pathComp in pathComponents)
{
NSLog(@"%@", pathComp);
}

[pathComponents release];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.