Skip to content

Instantly share code, notes, and snippets.

View Koze's full-sized avatar
:octocat:
Refactoring

Koze Koze

:octocat:
Refactoring
View GitHub Profile
@Koze
Koze / ShareViewController.m
Created May 14, 2015 16:35
ShareViewController example for Share Extension
#import "ShareViewController.h"
#import "TableViewController.h"
@interface ShareViewController ()
@property (nonatomic) SLComposeSheetConfigurationItem *item;
@end
@implementation ShareViewController
- (BOOL)isContentValid {
@Koze
Koze / PhotosCameraRoll.m
Last active June 4, 2025 05:54
Getting Camera Roll with Photos.framework
PHFetchResult *result = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum
subtype:PHAssetCollectionSubtypeSmartAlbumUserLibrary
options:nil];
PHAssetCollection *assetCollection = result.firstObject;
NSLog(@"%@", assetCollection.localizedTitle);
// Camera Roll
@Koze
Koze / DetectCarrier.m
Last active August 29, 2015 14:21
Detect Carrier
CTTelephonyNetworkInfo *telephonyNetworkInfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = telephonyNetworkInfo.subscriberCellularProvider;
NSLog(@"%@", carrier);
NSLog(@"%@", telephonyNetworkInfo.currentRadioAccessTechnology);
[telephonyNetworkInfo setSubscriberCellularProviderDidUpdateNotifier:^(CTCarrier *carrier) {
NSLog(@"%@", carrier);
}];
[[NSNotificationCenter defaultCenter] addObserverForName:CTRadioAccessTechnologyDidChangeNotification
object:nil
queue:[NSOperationQueue mainQueue]
@Koze
Koze / DetectCallState.m
Created May 21, 2015 15:54
Detect Call State
CTCallCenter *callCenter = [[CTCallCenter alloc] init];
[callCenter setCallEventHandler:^(CTCall *call) {
NSLog(@"%@", call.callState);
NSLog(@"%@", call.callID);
}];
@Koze
Koze / RemoteLogin.sh
Created May 24, 2015 14:39
Remote Login command with Apple Remote Desktop
osascript -e 'tell application "System Events"
keystroke "username"
keystroke tab
keystroke "password"
keystroke return
end tell'
@Koze
Koze / 1-RunApplication.scpt
Last active December 9, 2023 20:07
Launch application, Quit application with AppleScript
# launch application
tell application "TextEdit" to run
@Koze
Koze / CloseAllWindows.scpt
Last active November 1, 2022 17:11
Close all windows with AppleScript
tell application "Finder" to close windows
@Koze
Koze / ShareExtensionNavigationItem.m
Created May 28, 2015 15:04
Customize navigation item on share extension
- (void)viewDidLoad
{
[super viewDidLoad];
UIViewController *viewController = self.navigationController.viewControllers.firstObject;
UINavigationItem *navigationItem = viewController.navigationItem;
navigationItem.leftBarButtonItem.title = @"Button";
navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:nil action:nil];
UIImage *image = [UIImage imageNamed:@"emoji"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
@Koze
Koze / AccessEKSources.m
Created June 2, 2015 14:35
Access to all EKSources
EKEventStore *eventStore = [[EKEventStore alloc] init];
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
[eventStore requestAccessToEntityType:EKEntityTypeReminder completion:^(BOOL granted, NSError *error) {
NSLog(@"%@", eventStore.sources);
}];
}];
@Koze
Koze / DynamicTypeUI.m
Last active October 10, 2018 20:57
Dynamic Type for some UI components
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// UINavigationBar title
[[UINavigationBar appearance] setTitleTextAttributes:@{NSFontAttributeName: [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline]}];
// UIBarButtonItem title
[[UIBarButtonItem appearance] setTitleTextAttributes:@{NSFontAttributeName: [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]}
forState:UIControlStateNormal];
// UITabBarItem title
[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName: [UIFont preferredFontForTextStyle:UIFontTextStyleCaption1]}
forState:UIControlStateNormal];