Skip to content

Instantly share code, notes, and snippets.

@palaniraja
palaniraja / manifest.plist
Created June 28, 2011 13:46
App Manifest file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
@omz
omz / gist:1102091
Created July 24, 2011 01:40
Creating arbitrarily-colored icons from a black-with-alpha master image (iOS)
// Usage example:
// input image: http://f.cl.ly/items/3v0S3w2B3N0p3e0I082d/Image%202011.07.22%2011:29:25%20PM.png
//
// UIImage *buttonImage = [UIImage ipMaskedImageNamed:@"UIButtonBarAction.png" color:[UIColor redColor]];
// .h
@interface UIImage (IPImageUtils)
+ (UIImage *)ipMaskedImageNamed:(NSString *)name color:(UIColor *)color;
@end
@kristopherjohnson
kristopherjohnson / NSMutableURLRequest+KDJBasicAuthentication.h
Created March 26, 2013 15:52
Category on NSMutableURLRequest that sets HTTP "Authorization" header for basic access authentication, using code appropriated from AFNetworking
#import <Foundation/Foundation.h>
@interface NSMutableURLRequest (KDJBasicAuthentication)
// Sets the "Authorization" HTTP header to a basic authentication value
// with Base64-encoded username and password. This overwrites any existing
// value for this header.
- (void)setAuthorizationHeaderWithUsername:(NSString *)username
password:(NSString *)password;
@alexrrouse
alexrrouse / NSAttributedString+RZExtensions.h
Last active August 29, 2015 13:56
An Extension on NSAttributedString to allow for easier creation.
//
// NSAttributedString+RZExtensions.h
// Raizlabs
//
// Created by Alex Rouse on 12/13/13.
// Copyright 2014 Raizlabs and other contributors
// http://raizlabs.com/
//
// Permission is hereby granted, free of charge, to any person obtaining
@nicklockwood
nicklockwood / Deprecated.md
Last active March 28, 2022 08:16
Writing Objective-C framework code that works on multiple OS versions AND can be compiled using multiple SDK versions without warnings can be a PITA. Here's my approach:

Suppose we want to add support for a new iOS 8 API in our framework that replaces an older iOS 7 API. There are a few problems we might face:

  1. The new API will crash if we call it on iOS 7
  2. The new API won't compile if we build it using the iOS 7 SDK
  3. The old API will raise a deprecation warning if built with a deployment target of iOS 8 and up

These three problems require three different technical solutions:

  1. We can avoid calling the new API on an old OS version by using runtime detection (e.g. respondsToSelector:)
  2. We can avoid compiling new APIs on old SDKs using the __IPHONE_OS_VERSION_MAX_ALLOWED macro
@shashankpali
shashankpali / CocoaPods
Last active August 13, 2016 04:41
Uploading a pod
1. Make sure you have tagged a release version on GitHub.
2. The podspec file must contain the same version as GitHub.
// change git username
3. git config --global user.name MyName --replace-all
// change git email
4. git config --global user.email any@email --replace-all
@saoudrizwan
saoudrizwan / TaskManager.swift
Last active May 10, 2024 10:56
Handle multiple network requests with the same URL efficiently with a shared task manager
import Foundation
class TaskManager {
static let shared = TaskManager()
let session = URLSession(configuration: .default)
typealias completionHandler = (Data?, URLResponse?, Error?) -> Void
var tasks = [URL: [completionHandler]]()