Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion iOS_Processes/iOS_Processes/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ - (void)viewDidLoad
[super viewDidLoad];

NSArray *processes = [[UIDevice currentDevice] runningProcesses];
NSLog(@"");
NSLog(@"%@", processes);
}

- (void)didReceiveMemoryWarning
Expand Down
6 changes: 3 additions & 3 deletions iOS_Processes/iOS_Processes/src/UIDevice+Processes.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ - (NSArray *)runningProcesses
{

int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0};
size_t miblen = 4;
u_int miblen = 4;

size_t size;
int st = sysctl(mib, miblen, NULL, &size, NULL, 0);
Expand All @@ -42,13 +42,13 @@ - (NSArray *)runningProcesses
if (st == 0){

if (size % sizeof(struct kinfo_proc) == 0){
int nprocess = size / sizeof(struct kinfo_proc);
size_t nprocess = size / sizeof(struct kinfo_proc);

if (nprocess){

NSMutableArray * array = [[NSMutableArray alloc] init];

for (int i = nprocess - 1; i >= 0; i--){
for (size_t i = nprocess - 1; i > 0; i--){

NSString *processID = [[NSString alloc] initWithFormat:@"%d", process[i].kp_proc.p_pid];
NSString *processName = [[NSString alloc] initWithFormat:@"%s", process[i].kp_proc.p_comm];
Expand Down