Skip to content

Instantly share code, notes, and snippets.

View lamprosg's full-sized avatar

Lampros Giampouras lamprosg

  • Athens, Greece
View GitHub Profile
@lamprosg
lamprosg / ActionSheetController.mm
Created February 22, 2013 11:08
(iOS) ActionSheet and UIALert
//You need to add the <UIActionSheetDelegate> protocol in your .h file interface
//@interface BIDViewController : UIViewController <UIActionSheetDelegate>
//Action when a button is pressed
- (IBAction)buttonPressed:(id)sender {
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:@"Are you sure?"
delegate:self
cancelButtonTitle:@"No Way!"
@lamprosg
lamprosg / animateDropDownView.mm
Last active December 14, 2015 02:19
(iOS) Useful small actions and codes
//Check if a value exists in an NSMutableArray
if ([mutableArray indexOfObject:@"value"] == NSNotFound)
//Add rounded corners
CALayer * shareViewLayer = shareBlogView.layer;
[shareViewLayer setMasksToBounds:YES];
[shareViewLayer setCornerRadius:5.0];
//Add shadow to a view
@lamprosg
lamprosg / AppDelegate.mm
Last active December 14, 2015 02:29
(iOS) Creating a tab bar
//Create for every single view you're going to have a new view controller class
//Subclass of UIViewController
//With a correspoding .xib
//.
//Creating outlet for the root controller (which will be a tab bar) in the delegate .h file
@property (strong, nonatomic) IBOutlet UITabBarController *tabBarController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
@lamprosg
lamprosg / social.h
Last active January 3, 2016 14:03
(iOS) iOS6 Social framework
Official Twitter API (Has all the service URLs)
https://dev.twitter.com/docs/api/1.1
#import <Foundation/Foundation.h>
#import <Social/Social.h>
#import <Accounts/Accounts.h>
//Twitter GET USER INFO Service URL
//https://dev.twitter.com/docs/api/1.1/get/users/show
#define TWITTERGETUSERINFOURL @"https://api.twitter.com/1.1/users/show.json"
@lamprosg
lamprosg / 1.tableViewController.h
Last active December 14, 2015 03:29
(iOS) Simple TableView (no navigation)
//Drag a Table View object from the library onto the .xib (it will cover all the screen
//Connect the dataSource and delegate outlets (from the connection inspector)
//of the Table View component to the view controller (File's Owner)
//Use those 2 protocols
@interface TableExampleViewController : UIViewController<UITableViewDelegate, UITableViewDataSource>
//The data themselves
@property (strong, nonatomic) NSArray *colorNames;
@property (strong, nonatomic) IBOutlet UITableView *mainTable;
@lamprosg
lamprosg / AppDelegate.mm
Last active December 14, 2015 03:59
(iOS) Navigation based application - using TableViews
//Create for every single view you're going to have a new view controller class
//Subclass of UIViewController or UITableViewController if it's tableview based
//With a correspoding .xib
//Import the first view controller class that will be displayed in the .h file
#import firstViewController.h
//Creating outlet for the navigation controlle in the delegate .h file
@property (strong, nonatomic) UINavigationController *navigationController;
//OR (for the 2d way (look below)
@lamprosg
lamprosg / appDelegate.mm
Created February 25, 2013 14:27
(iOS) UIWebView
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
/*****************************************************************************************/
//intialize the root controller, with the the SwitchView nib.
self.webViewController = [[BIDWebViewController alloc] initWithNibName:@"Web" bundle:nil];
@lamprosg
lamprosg / Read me
Last active December 14, 2015 05:40
(iOS) - Property Lists
Every application has 3 folders in it.
1. Documents: Where data are stored, except NSUserDefaults–based preference settings.
2. Library: NSUserDefaults–based preference settings are stored here
3. tmp: Temporary files are stored here. Files written into tmp will not be backed up by iTunes when your iOS device syncs.
(You still need to delete these files to avoid filling up the file system.)
/******************************************/
@lamprosg
lamprosg / Read me:
Created February 26, 2013 10:12
(iOS) - Core Data [incomplete]
An entity is made up of properties. There are three types of properties:
Attributes: An attribute serves the same function in a Core Data entity as an instance variable does in an Objective-C class.
They both hold the data.
Relationships: As the name implies, a relationship defines the relationship between entities.
For example, to create a Person entity, you might start by defining a few attributes such as hairColor, eyeColor, height
and weight. You might define address attributes, such as state and ZIP code, or you might embed them in a separate HomeAddress
entity.
@lamprosg
lamprosg / 0.Maps.mm
Last active December 18, 2017 08:49
(iOS) Core Location & Map Kit
/**************************************/
//Annotation object
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface MapViewAnnotation : NSObject <MKAnnotation>
@property (nonatomic,strong) NSString *title;
@property (nonatomic,strong) NSString *subtitle;
@property (nonatomic, assign) CLLocationCoordinate2D coordinate;