Skip to content

Instantly share code, notes, and snippets.

Yin Cheng msching

Block or report user

Report or block msching

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
msching / addressesForHostname.m
Last active May 9, 2016
View addressesForHostname.m
+ (NSArray *)addressesForHostname:(NSString *)hostname
if (!hostname)
return nil;
// Get the addresses for the given hostname.
CFHostRef hostRef = CFHostCreateWithName(kCFAllocatorDefault, (__bridge CFStringRef)hostname);
BOOL isSuccess = CFHostStartInfoResolution(hostRef, kCFHostAddresses, nil);
msching / AVPlayerCaching.m
Last active Aug 15, 2016 — forked from anonymous/AVPlayerCaching.m
using localfile if file is created
View AVPlayerCaching.m
// ViewController.m
// AVPlayerCaching
// Created by Anurag Mishra on 5/19/14.
// Sample code to demonstrate how to cache a remote audio file while streaming it with AVPlayer
#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
msching / updateNowPlayingCenter
Last active Mar 30, 2016
update NowPlayingCenterInfo for iOS 8.2 (even if you only wish to update the artwork).
View updateNowPlayingCenter
- (void)updateNowPlayingCenter:(NSDictionary *)info
NSString *zeroLengthString = @"\u200B";
NSString *title = info[MPMediaItemPropertyTitle];
NSString *currentTitle = [MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo[MPMediaItemPropertyTitle];
NSUInteger index = [currentTitle rangeOfString:zeroLengthString].location;
if (index == NSNotFound)
msching / UIDevice + ProcessesAdditions
Created Feb 27, 2015
A UIDevice category for getting the running processes on an iOS device. Based on something floating about on the web by Landon Fuller. Cleaned it up a bit and changed so it returns an NSArray of NSDictionary[s].
View UIDevice + ProcessesAdditions
// .h
@interface UIDevice (ProcessesAdditions)
- (NSArray *)runningProcesses;
// .m
#import <sys/sysctl.h>
@implementation UIDevice (ProcessesAdditions)
You can’t perform that action at this time.