Showing posts with label privateFrameworksPath. Show all posts
Showing posts with label privateFrameworksPath. Show all posts

Monday, April 29, 2013

NSBundle privateFrameworksPath example ios


privateFrameworksPath

Returns the full pathname of the receiver's subdirectory containing private frameworks.
- (NSString *)privateFrameworksPath
Return Value
The full pathname of the receiver's subdirectory containing private frameworks.
Discussion of [NSBundle privateFrameworksPath]
This method returns the appropriate path for modern application and framework bundles. This method may not return a path for non-standard bundle formats or for some older bundle formats.
Example of [NSBundle privateFrameworksPath]
//------------------------------------------------------
-(void) runScript:(NSString*)scriptName
{
    NSTask *task;
    task = [[NSTask alloc] init];
    [task setLaunchPath: @"/bin/sh"];

    NSArray *arguments;
    NSString* newpath = [NSString stringWithFormat:@"%@/%@",[[NSBundle mainBundle] privateFrameworksPath], scriptName];
    NSLog(@"shell script path: %@",newpath);
    arguments = [NSArray arrayWithObjects:newpath, nil];
    [task setArguments: arguments];

    NSPipe *pipe;
    pipe = [NSPipe pipe];
    [task setStandardOutput: pipe];

    NSFileHandle *file;
    file = [pipe fileHandleForReading];

    [task launch];

    NSData *data;
    data = [file readDataToEndOfFile];

    NSString *string;
    string = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
    NSLog (@"script returned:\n%@", string);    
}
//------------------------------------------------------