Last active
March 27, 2019 18:43
-
-
Save Beyarz/9eb74da0a5cb83355e395e1bb093e18e to your computer and use it in GitHub Desktop.
An effective way of removing prefix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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