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

nightwalker21

macrumors newbie
Original poster
Jul 27, 2011
18
0
USA
I'm needing help with implementing NSFileManager into my app to do things like in my bash scripts below.

hidemyx code:

Code:
#!/bin/bash 
mv -f "/Applications/IntelliScreenX.app/Info.plist" "/Applications/HideMyX.app/show/"

cp -f "/Applications/HideMyX.app/hide/Info.plist" "/Applications/IntelliScreenX.app/"

showmyx code:

Code:
#!/bin/bash 
rm -f “/Applications/IntelliScreenX.app/Info.plist”

mv -f "/Applications/HideMyX.app/show/Info.plist" "/Applications/IntelliScreenX.app/"

I've been told to use NSFileManager instead of system().

Here is my app code itself:

Code:
#import "RootViewController.h"
#import <UIKit/UIKit.h>

@implementation RootViewController
- (void)viewDidLoad {
	self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
	self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Background"]];
    
    UIButton *hideButton = [[UIButton alloc] init];
    hideButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
    hideButton.frame = CGRectMake(10, 100, 90, 40);
    [hideButton setTitle:@"Hide Icon" forState:UIControlStateNormal];
    [hideButton setBackgroundImage:[UIImage imageNamed:@"hide.png"]
                        forState:UIControlStateNormal];
    [hideButton addTarget:self action:@selector(hideButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:hideButton];
    
    UIButton *showButton = [[UIButton alloc] init];
    showButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
    showButton.frame = CGRectMake(115, 100, 90, 40);
    [showButton setTitle:@"Show Icon" forState:UIControlStateNormal];
    [showButton setBackgroundImage:[UIImage imageNamed:@"show.png"]
                        forState:UIControlStateNormal];
    [showButton addTarget:self action:@selector(showButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:showButton];
    
    UILabel *supportLabel = [[UILabel alloc] initWithFrame:CGRectMake(21, 200, self.view.frame.size.width - 20, 44)];
    supportLabel.text = @"Visit deathscreations.22web.org for support make sure to create your topic in the right area";
    supportLabel.backgroundColor = [UIColor clearColor];
    supportLabel.textColor = [UIColor greenColor];
    supportLabel.textAlignment = UITextAlignmentLeft;
    supportLabel.lineBreakMode = NSLineBreakByWordWrapping;
    supportLabel.numberOfLines = 10;
    [self.view addSubview:supportLabel];
    [supportLabel release];
    
    UILabel *respringLabel = [[UILabel alloc] initWithFrame:CGRectMake(21, 350, self.view.frame.size.width - 20, 44)];
    respringLabel.text = @"Device will Respring when finished";
    respringLabel.backgroundColor = [UIColor clearColor];
    respringLabel.textColor = [UIColor greenColor];
    respringLabel.textAlignment = UITextAlignmentLeft;
    [self.view addSubview:respringLabel];
    [respringLabel release];

}

-(void)hideButtonPressed
{
    system("/usr/bin/hidemyx");
}

-(void)showButtonPressed
{
    system("/usr/bin/showmyx");
}
@end

This is the log coming from the app with the way I have it programed now
 
Last edited:
Isn't that operation just going to cause the apps to fail signature check when they start? Or does jailbreaking disable that checking?
 
So your log says
2014-07-10 13:30:57.671 HideMyX_[1414:e07] -[RootViewController hideButtonPressed:]: unrecognized selector sent to instance 0x151820
2014-07-10 13:30:57.676 HideMyX_[1414:e07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RootViewController hideButtonPressed:]: unrecognized selector sent to instance 0x151820'

Your target action says the following which is displayed in the error message
Code:
[hideButton addTarget:self action:@selector(hideButtonPressed:) forControlEvents:UIControlEventTouchUpInside];

Your method name doesn't match the taget
Code:
-(void)hideButtonPressed
{
    system("/usr/bin/hidemyx");
}

You need to remove the colons from your target definition or properly setup you methods to match the selector name in your target for passing an object.


As for trying to mess with your plist files, I have my doubts that will be allowed, but I'm not sure what you're up to.
 
I understand what my code is suppose to do. This app only works with jailbroken devices. I got the code fixed just need to know how to use NSFileManager to do what my scripts are wrote for.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.