Skip to content

Instantly share code, notes, and snippets.

@Beyarz
Last active March 27, 2019 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Beyarz/9eb74da0a5cb83355e395e1bb093e18e to your computer and use it in GitHub Desktop.
Save Beyarz/9eb74da0a5cb83355e395e1bb093e18e to your computer and use it in GitHub Desktop.
An effective way of removing prefix
// Raw data
NSString *appname = @"<NSRunningApplication: 0x600000107d70 (com.apple.iChat - 8272)>";
// Splitting address & appname
NSArray *splitted = [appname componentsSeparatedByString:@" "];
// Getting the pid
NSString *pid = [splitted objectAtIndex:2];
if([pid hasPrefix:@"("]){
// Splitting the unwanted with wanted
NSArray *rmprefix = [pid componentsSeparatedByString:@"("];
// Retrieving the filtered pid
pid = [rmprefix objectAtIndex:1];
}
NSLog(@"%@", pid);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment