Skip to content

Instantly share code, notes, and snippets.

@melsam
melsam / TwitterStatusUpdateWithoutUI.m
Last active October 24, 2016 12:05
Post a Twitter status update without using any of the built-in UI on iOS. This uses the Twitter 1.1 API (not the deprecated REST APIs).
@import Accounts;
#import <Twitter/Twitter.h>
- (void)postTwitterStatusUpdate:(NSString *)statusMessage
{
ACAccountStore *account = [ACAccountStore new];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[account requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {
if (granted) {
@steipete
steipete / FilterScriptPhase.sh
Created April 27, 2015 16:25
This filter script phase is required to remove unused architectures from your application, which would be flagged as issue during upload to the Apple AppStore. Read more at http://ikennd.ac/blog/2015/02/stripping-unwanted-architectures-from-dynamic-libraries-in-xcode/
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
@cromandini
cromandini / universal-framework.sh
Last active November 9, 2024 08:56 — forked from cconway25/gist:7ff167c6f98da33c5352
This run script will build the iphoneos and iphonesimulator schemes and then combine them into a single framework using the lipo tool (including all the Swift module architectures).
#!/bin/sh
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
@alexcristea
alexcristea / install-manifest.plist
Last active January 31, 2023 11:53
Over-the-Air Ad Hoc Distribution manifest for iOS8. More about this subject you can find on http://www.informit.com/articles/article.aspx?p=1829415&seqNum=16
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- array of downloads. -->
<key>items</key>
<array>
<dict>
<!-- an array of assets to download -->
@maddiesch
maddiesch / DrawView.h
Created December 3, 2013 21:50
Simple drawing view based on UIPanGestureRecognizer.
#import <UIKit/UIKit.h>
@interface DrawView : UIView
@property (nonatomic) CGMutablePathRef drawingPath;
@property (nonatomic) CGPoint lastPoint;
@end
@sag333ar
sag333ar / twoDaysAgo.m
Created December 3, 2013 12:50
* 'just now' * '2 minutes ago' * '24 days ago' * 'a month ago' Manipulate date & get data in string format as above.
+ (NSString *)stringForTimeIntervalSinceCreated:(NSDate *)dateTime serverTime:(NSDate *)serverDateTime{
NSInteger MinInterval;
NSInteger HourInterval;
NSInteger DayInterval;
NSInteger DayModules;
NSInteger interval = abs((NSInteger)[dateTime timeIntervalSinceDate:serverDateTime]);
if(interval >= 86400) {
DayInterval = interval/86400;
DayModules = interval%86400;
@JigsChanchiya
JigsChanchiya / customswipetodelete.mm
Created October 16, 2013 05:08
In uitableview performs the swipe action with custom delete button.
/*
This method will be called when user performs the swipe action
Just Place this in your CustomCell
*/
- (void)willTransitionToState:(UITableViewCellStateMask)state
@JigsChanchiya
JigsChanchiya / Keybord+Notification+iOS.mm
Created October 15, 2013 12:08
Keybord notifications in OS
/*
UIKeyboardWillShowNotification
UIKeyboardDidShowNotification
UIKeyboardWillHideNotification
UIKeyboardDidHideNotification
*/
@JigsChanchiya
JigsChanchiya / UIImageView+Download.mm
Created October 11, 2013 04:51
Download image from url async
#import "UIImageView+Download.h"
@implementation UIImageView (Download)
-(void)downloadFromURL:(NSString *)url withPlaceholder:(UIImage *)placehold
{
if (placehold) {
[self setImage:placehold];
}
if (url) {