RestartSpringBoard with objective-c

Discussion in 'iOS Development' started by gojohnnyboi, Apr 2, 2008.

  1. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    Hey guys i was wondering if somebody could display how to simply restart the springboard in objective-c.

    I would greatly appreciate it.



    Also, how to execute a command. Thanks very much.
  2. jeppeb

    jeppeb New Member

    Joined:
    Apr 3, 2008
    Messages:
    14
    Likes Received:
    0
    I'm doning it like this:
    Code:
    - (void)runCommand: (int) commandTxt {
    	whichAction2 = [NSString stringWithFormat: commandTxt];
    	char *cmd2 = [whichAction2 UTF8String];
    	FILE *fp2 = popen(cmd2, "r");
    	if (fp2 == NULL) {
    		NSLog(@"popen failed"); 
    		exit(1);
    	}
    
       NSString *riz2 = @"";
       int c2;
       int kBlockSize = 512;
    
       do {
           char buf2[kBlockSize];
           c2 = fread(buf2, sizeof(char), kBlockSize, fp2);
           if (c2 <= 0) break;
           buf2[c2] = '\0';   
           riz2 = [riz2 stringByAppendingString:
               [NSString stringWithCString:buf2 encoding:1]];
       } while (1);
    }
    Than you can restart springboard like this:
    Code:
    [self runCommand:@"/bin/launchctl stop com.apple.SpringBoard"];
  3. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55


    the thing is i want it to execute a command on the alertsheet button click
  4. jeppeb

    jeppeb New Member

    Joined:
    Apr 3, 2008
    Messages:
    14
    Likes Received:
    0
    So?

    You can call [self runCommand

    Please Register or Log in to view images

    "..."] from anywhere, also after an alert click.
  5. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55


    ok hold on im trying now.
  6. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    Or, you could just tell the system to run your command. For example:
    Code:
    system("launchctl stop com.apple.SpringBoard");
  7. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55


    Thanks. I knew that from c but I didn't know it applied to obj c. Thanks!

Share This Page