Skip to content

Instantly share code, notes, and snippets.

@nakiwo
nakiwo / gist:3063673
Created July 7, 2012 01:04
自分でviewをunloadする
- (void)didReceiveMemoryWarning
{
if([self isViewLoaded] && self.view.window == nil) {
// viewWillUnloadでやっていた処理を書く
self.view = nil;
// viewDidUnloadでやっていた処理を書く
}
[super didReceiveMemoryWarning];
}
@nakiwo
nakiwo / gist:3174351
Created July 25, 2012 04:15
subviewだけtouchできるview
@interface TestView : UIView
@end
@implementation TestView
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
UIView *view = [super hitTest:point withEvent:event];
if(view == self) {
return nil;
@nakiwo
nakiwo / gist:3179598
Created July 26, 2012 00:46
Xcode4.4 iOS SDKで @yES,@no,array[...],dictionary[...]を使う
// Xcode4.4
// llvm4の機能のうち一部が、
// iOS 5.1 SDK で使えない
// 例
NSNumber *b = @YES; // error
NSArray *array = @[ @1, @2, @3 ];
NSNumber *n = array[1]; // error
@nakiwo
nakiwo / gist:5500639
Created May 2, 2013 07:14
rubycocoaでplist生成
require 'osx/cocoa'
data = OSX::NSPropertyListSerialization.dataWithPropertyList_format_options_error_(obj, OSX::NSPropertyListBinaryFormat_v1_0, 0, nil)
data.writeToFile_atomically_(path, true)
@nakiwo
nakiwo / isEqual
Last active August 29, 2015 13:56
BOOL isEqual(NSObject *a, NSObject *b)
{
if (a) {
if (b) {
return [a isEqual:b];
}
} else { // a == nil
if (!b) {
return YES;
}
@nakiwo
nakiwo / gist:e5e28124afbe4d32b490
Last active August 29, 2015 14:02
SSID取得
@import SystemConfiguration;
#import <SystemConfiguration/CaptiveNetwork.h>
- (NSString *)currentSSID
{
NSArray *interfaceNames = CFBridgingRelease(CNCopySupportedInterfaces());
if (!interfaceNames.count) {
return nil;
}
@nakiwo
nakiwo / gist:c7c8d56cfb1c64c8617e
Created August 19, 2014 02:19
embedded.mobileprovisionにあるplistを取得
- (NSDictionary *)embeddedMobileprovisionPlist
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"];
if (!path) {
return nil;
}
NSData *profileData = [NSData dataWithContentsOfFile:path];
if (!profileData) {
return nil;
@nakiwo
nakiwo / gist:afc59f05147d9526d7d5
Created March 25, 2015 03:05
dump mobileprovision as text
openssl asn1parse -inform DER -in foo.mobileprovision
// Swift 3
import UIKit
class TestViewController: UIViewController {
var text: String!
static func create(with text: String) -> Self {
let vc = instantiateFromStoryboard()