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
msching / addressesForHostname.m
Last active May 9, 2016
addressesForHostname
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
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
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
{
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.2") && SYSTEM_VERSION_LESS_THAN(@"8.3"))
{
NSString *zeroLengthString = @"\u200B";
NSString *title = info[MPMediaItemPropertyTitle];
NSString *currentTitle = [MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo[MPMediaItemPropertyTitle];
NSUInteger index = [currentTitle rangeOfString:zeroLengthString].location;
if (index == NSNotFound)
{
@msching
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;
@end
// .m
#import <sys/sysctl.h>
@implementation UIDevice (ProcessesAdditions)
You can’t perform that action at this time.