Skip to content

Instantly share code, notes, and snippets.

View Adnan1990's full-sized avatar

Muhammad Adnan Adnan1990

View GitHub Profile
@Adnan1990
Adnan1990 / deleteTableviewRow.m
Created January 13, 2015 10:31
Tableview Swipe row to delete
// During startup (-viewDidLoad or in storyboard) do:
self.tableView.allowsMultipleSelectionDuringEditing = NO;
// Override to support conditional editing of the table view.
// This only needs to be implemented if you are going to be returning NO
// for some items. By default, all items are editable.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// Return YES if you want the specified item to be editable.
return YES;
-(BOOL) IsValidPhoneNumber:(NSString*) phoneNumber
{
//NSString *phoneRegex = @"[235689][0-9]{6}([0-9]{3})?";
NSString *phoneRegex = @"^((\\+)|(00))[0-9]{6,14}$";
NSPredicate *test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", phoneRegex];
return [test evaluateWithObject:phoneNumber];
}
- (BOOL) NSStringIsValidEmail:(NSString *)checkString
{
@Adnan1990
Adnan1990 / UIView+Toast.h
Created November 3, 2014 08:22
Create toast like android
/***************************************************************************
UIView+Toast.h
Toast
Copyright (c) 2014 Charles Scalesse.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
@Adnan1990
Adnan1990 / disableSelectedTab.m
Created September 16, 2014 07:28
Avoid already selected tab from selection again
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
return viewController != self.tabBarController.selectedViewController;
}
@Adnan1990
Adnan1990 / NSUserDefaults.m
Last active August 29, 2015 14:01
Setting ,Getting and removing objects From NSUserDefaults
//Setting Obejct Using NSUserDefaults
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setValue:@"successfull" forKey:@"loggedIn"];
[defaults synchronize]; //use this method only if you cannot wait for the automatic synchronization
//Getting Object using NSUserDefaults
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSLog(@"loggedIn is %@",[defaults objectForKey:@"loggedIn"]);
@Adnan1990
Adnan1990 / Submitting App To appstore
Created April 28, 2014 13:09
App Submission Process
https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/SubmittingYourApp/SubmittingYourApp.html
@Adnan1990
Adnan1990 / HelloWorldScene.m
Created April 28, 2014 11:09
Animations in Cocos2d V3.0
//
// HelloWorldScene.m
// animation
//
// Created by Muhammad Adnan on 28/04/2014.
// Copyright Vizteck Solutions 2014. All rights reserved.
//
// -----------------------------------------------------------------------
#import "HelloWorldScene.h"
@Adnan1990
Adnan1990 / learnCocos2d
Created April 3, 2014 11:10
Cocos2d[ A towards Z]
Install latest cocos version (currently v3.0 dmg file is installable)
@Adnan1990
Adnan1990 / ARC + -
Created March 20, 2014 11:52
Adding or Removing ARC from Single File
If you want to exclude a file from being compiled with ARC you can do so by setting a flag on the .m file:
Click the Project -> Build Phases Tab -> Compile Sources Section -> Double Click on the file name
Then add -fno-objc-arc to the popup window.
Likewise, if you want to include a file in ARC, you can use the -fobjc-arc flag.
@Adnan1990
Adnan1990 / versions.m
Last active August 29, 2015 13:57
IOS version
/*
* System Versioning Preprocessor Macros
*/
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)