Skip to content

Instantly share code, notes, and snippets.

View Adnan1990's full-sized avatar

Muhammad Adnan Adnan1990

View GitHub Profile
@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 / 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 / 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
-(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 / 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;
//Disabling ios cache and getting remote data
[[NSURLCache sharedURLCache] removeAllCachedResponses];
#import <Foundation/Foundation.h>
@interface MyCalendar : NSObject
+ (void)requestAccess:(void (^)(BOOL granted, NSError *error))success;
+ (BOOL)addEventAt:(NSDate*)eventDate withTitle:(NSString*)title inLocation:(NSString*)location;
@end
@Adnan1990
Adnan1990 / imageReadWrite.m
Last active August 29, 2015 14:22
Saving and retrieving images to or from document directory
//The following function saves UIImage in test.png file in the user Document folder:
- (void)saveImage: (UIImage*)image
{
if (image != nil)
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString* path = [documentsDirectory stringByAppendingPathComponent:
@Adnan1990
Adnan1990 / Sift+objective c Awesome.
Created August 26, 2015 05:45
Swift and objective c resources
Collaborative List of Open-Source iOS Apps
https://github.com/dkhamsing/open-source-ios-apps#official
awesome swift
https://github.com/matteocrippa/awesome-swift
Awesome IOS
https://github.com/vsouza/awesome-ios
@Adnan1990
Adnan1990 / CustomTextField.h
Created December 16, 2015 05:20
Customizing TextField Placeholder
//
// CustomTextField.h
// LMKT
//
// Created by Adnan on 12/15/15.
//
//
#import <UIKit/UIKit.h>