Skip to content

Instantly share code, notes, and snippets.

View jchudzynski's full-sized avatar

Janusz Chudzynski jchudzynski

View GitHub Profile
@jchudzynski
jchudzynski / tableviewformat.m
Created February 4, 2014 20:44
Formatting table view's cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyReuseIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:MyIdentifier];
}
// format the cell
cell.textLabel.text =@"";
cell.imageView.image =[UIImage imageNamed:@"icon"];
@jchudzynski
jchudzynski / tableViewExample.m
Created February 4, 2014 19:50
UITableViewDataSource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyReuseIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier];
}
// format the cell
return cell;
}
@jchudzynski
jchudzynski / Deck.m
Created January 13, 2014 22:27
Deck.m used to show how to parse XML documents.
#import "Deck.h"
@implementation Deck
-(instancetype)init{
if(self= [super init]){
_questions = [NSMutableArray new];
}
return self;
}
@jchudzynski
jchudzynski / Deck.h
Created January 13, 2014 22:25
Deck.h created to show how to parse XML documents.
#import <Foundation/Foundation.h>
@interface Deck : NSObject
@property(nonatomic, strong) NSMutableArray * questions;
@property(nonatomic, strong) NSString * name;
@end
@jchudzynski
jchudzynski / XMLParser.m
Last active January 3, 2016 03:49
NSXMLParser Example
// XMLParser.m
// CDT
// Created by Janusz Chudzynski on 1/13/14.
#import "XMLParser.h"
#import "Deck.h"
#import "Question.h"
typedef void (^SuccessBlock)(NSData *);
@jchudzynski
jchudzynski / IsConnected
Created January 13, 2014 16:40
Checks if internet connection is offline.
-(BOOL)checkIfOnline{
NSURL *scriptUrl = [NSURL URLWithString:@"http://google.com/m"];
NSData *data = [NSData dataWithContentsOfURL:scriptUrl];
if (data){
NSLog(@"Device is connected to the internet");
return YES;}
else
NSLog(@"Device is not connected to the internet");
return NO;
@jchudzynski
jchudzynski / KVOOperationQueue.m
Last active October 24, 2016 18:17
KVO of NSOperationQueue
@interface KVOOperationQueue()
@property(nonatomic, strong) NSOperationQueue *queue;
@end
@implementation KVOOperationQueue
-(id)init{
self = [super init];
if(self){
filePath = filename;
@jchudzynski
jchudzynski / MinValue
Last active December 30, 2015 19:39
Getting a min value of CoreData entity.
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Slide" inManagedObjectContext:[[manager getAppDelegate]managedObjectContext]];
[request setEntity:entity];
// Specify that the request should return dictionaries.
[request setResultType:NSDictionaryResultType];
NSExpression *keyPathExpression = [NSExpression expressionForKeyPath:@"order"];
// Create an expression to represent the minimum value at the key path 'creationDate'
NSExpression *minExpression = [NSExpression expressionForFunction:@"min:" arguments:[NSArray arrayWithObject:keyPathExpression]];
@jchudzynski
jchudzynski / gist:7794260
Last active December 30, 2015 07:09
WebServicesHelper Example of usage in AppDelegate class
#import "AppDelegate.h"
#import "WebServicesHelper.h"
@interface AppDelegate()
@property (nonatomic,strong)WebServicesHelper * helper;
@end
@implementation AppDelegate
@jchudzynski
jchudzynski / WebServicesHelper.h
Created December 3, 2013 21:42
Contains methods that are making networking calls and parse the response
/*!
@class WebServicesHelper
@abstract
Contains methods that are making networking calls and parse the response
@discussion
respond to, e.g., authentication challenges
*/