Resolved NSFileManager?

Discussion in 'iOS Programming' started by nightwalker21, Jul 10, 2014.

  1. nightwalker21, Jul 10, 2014
    Last edited: Jul 10, 2014

    nightwalker21 macrumors newbie

    nightwalker21

    Joined:
    Jul 27, 2011
    Location:
    USA
    #1
    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
     
  2. mfram macrumors 65816

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #2
    Isn't that operation just going to cause the apps to fail signature check when they start? Or does jailbreaking disable that checking?
     
  3. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #3
    So your log says
    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.
     
  4. JohnsonK macrumors regular

    Joined:
    Mar 6, 2014
    #4
    Before we can help you, do you understand what your current code is doing?
     
  5. nightwalker21 thread starter macrumors newbie

    nightwalker21

    Joined:
    Jul 27, 2011
    Location:
    USA
    #5
    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.
     
  6. JohnsonK macrumors regular

    Joined:
    Mar 6, 2014
    #6
  7. nightwalker21 thread starter macrumors newbie

    nightwalker21

    Joined:
    Jul 27, 2011
    Location:
    USA
    #8
    PhoneyDeveloper thank you, I also thank everyone else for helping
     

Share This Page