Beginning iPhone Programming Question

Discussion in 'iOS Programming' started by TechnoEagle, Feb 2, 2010.

  1. TechnoEagle macrumors newbie

    Joined:
    Jan 30, 2010
    #1
    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
     
  2. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #2
    Exactly what can't you figure out about this assignment?
     
  3. TechnoEagle thread starter macrumors newbie

    Joined:
    Jan 30, 2010
    #3
    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.
     
  4. FarSeide macrumors 6502a

    FarSeide

    Joined:
    Feb 17, 2008
    Location:
    Earth Lane
    #5
    NSArray *pathComponents = [[NSArray alloc] init];
    pathComponents = [path pathComponents];

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

    [pathComponents release];
     

Share This Page