Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Chris Jungmann jungchris

🏠
Working from home
View GitHub Profile
@jungchris
jungchris / uploadToServerUsingImage
Created Feb 24, 2015
iOS HTTP Image Upload to Web Server
View uploadToServerUsingImage
// HTTP method to upload file to web server
- (void)uploadToServerUsingImage:(NSData *)imageData andFileName:(NSString *)filename {
// set this to your server's address
NSString *urlString = @"http://fineuploader.com/demos.html#amazon-demo";
// set the content type, in this case it needs to be: "Content-Type: image/jpg"
// Extract 'jpg' or 'png' from the last three characters of 'filename'
if (([filename length] -3 ) > 0) {
NSString *contentType = [NSString stringWithFormat:@"Content-Type: image/%@", [filename substringFromIndex:[filename length] - 3]];
}
@jungchris
jungchris / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jungchris
jungchris / AppDelegate.m
Last active Aug 29, 2015
Initiate Storyboard Programmatically
View AppDelegate.m
- (void)applicationDidBecomeActive:(UIApplication *)application
{
if (!application.keyWindow.rootViewController)
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *myViewController= [storyboard instantiateViewControllerWithIdentifier:@"myViewController identifier"];
application.keyWindow.rootViewController = myViewController;
}
@jungchris
jungchris / CCJMainViewController
Created Apr 17, 2015
Objective-C Code to Create an NSArray of Configured UIButtons
View CCJMainViewController
// Create array of Status Indicator UIButtons based on Andrew's 'configuredButton' method
- (void)defineStatusIndicatorButtons {
CGRect r = CGRectMake(0, 0, [[self.columnPlacementArray objectAtIndex:0] floatValue] + kButtonOffsetX, [[self.rowPlacementArray objectAtIndex:0] floatValue] + kButtonOffsetY);
self.arrayInfoButtons = [NSMutableArray arrayWithObjects:
(self.buttonStatusIndicatorPS = [self configuredStatusButton:r normalTitle:@"S" highlightTitle:@"possSm"]),
(self.buttonStatusIndicatorPM = [self configuredStatusButton:r normalTitle:@"M" highlightTitle:@"possMd"]),
(self.buttonStatusIndicatorPL = [self configuredStatusButton:r normalTitle:@"L" highlightTitle:@"possLg"]),
(self.buttonStatusIndicatorSS = [self configuredStatusButton:r normalTitle:@"S" highlightTitle:@"saleSm"]),
(self.buttonStatusIndicatorSM = [self configuredStatusButton:r normalTi
@jungchris
jungchris / CCJLocationManager.m
Created Apr 17, 2015
Reverse GeoCoder using CLLocationManager
View CCJLocationManager.m
// didUpdateToLocation is deprecated, replaced with didUpdateToLocations with an array
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
// code in case I need to get more than one location
int objCount = [locations count];
NSLog(@"MapVC: Delegate: didUpdateLocationS - objects count = %u", objCount);
if (objCount > 1) {
CLLocation *oldLocation = [locations objectAtIndex:objCount - 1];
NSLog(@"Prior location %f,%f", oldLocation.coordinate.latitude, oldLocation.coordinate.longitude);
@jungchris
jungchris / ViewFonts.m
Created May 2, 2015
Function to iterate available iOS Fonts
View ViewFonts.m
// Source: http://codewithchris.com/common-mistakes-with-adding-custom-fonts-to-your-ios-app/
- (void)viewDidLoad {
[super viewDidLoad];
// iterate through all available fonts
for (NSString* family in [UIFont familyNames])
{
NSLog(@"%@", family);
for (NSString* name in [UIFont fontNamesForFamilyName: family])
{
NSLog(@" %@", name);
@jungchris
jungchris / SponsorTableVC.m
Created Aug 20, 2015
createIndexOfSponsorsInOrganizations
View SponsorTableVC.m
// this method creates an index of the sponsors within organizations
- (void)createIndexOfSponsorsInOrganizations {
// sort first
[self createdSortedArrayOfSponsors];
// prepare new mutable array
NSMutableArray *sponsors = [[NSMutableArray alloc] init];
for (int i = 0; (i < [self.sortedArray count]); i++) {
// check each org and add those with organizationSposorLevel > 0
int sponsorLevel = [self.sortedArray[i] organizationSponsorLevel];
// add
@jungchris
jungchris / SponsorDetailVC.m
Last active Aug 29, 2015
ViewDidLoad Sets View Using indexOfIdInOrganizationsArray
View SponsorDetailVC.m
- (void)viewDidLoad {
[super viewDidLoad];
// NSLog(@"Sponsor #: %li", (long)self.selectedRow);
// set view
NSInteger orgIndex = [SharedConferenceObject indexOfIdInOrganzationsArray:[NSNumber numberWithInteger:self.selectedRow]];
if ((NSNotFound == orgIndex) || (orgIndex >= [SharedConferenceObject.organizationsArray count])) {
// there's a problem ...
NSLog(@"CATCH: SponsorDetailVC array index notFound/bounds for selectedRow: %lu", (long)self.selectedRow);
} else {
// Everything's Ok, display everything wanted
@jungchris
jungchris / ConferenceModel.m
Created Aug 20, 2015
indexOfIdInOrganzationsArray
View ConferenceModel.m
// used to determine correct location of object in array
- (NSInteger)indexOfIdInSessionsArray:(NSNumber*)inputNum {
// simple loop. Could use containsObject instead
for (NSInteger i = 0; i < [self.sessionsArray count]; i++) {
// check for NSNumber object equality
SessionsModel *session = self.sessionsArray[i];
if ([session.sessionId isEqual:inputNum]) {
return i;
}
}
@jungchris
jungchris / CCJNotificationEngine.m
Created Aug 20, 2015
Capitalizing Notification Name
View CCJNotificationEngine.m
NSString *notificationName = [CCJNotificationEngine notificationTargetRandomizer];
NSString *notificationTitle;
if (notificationName) {
if (notificationName.length > 1) {
// NSString *uppercaseFirstLetter = [notificationName stringByReplacingCharactersInRange:NSMakeRange(0,1)
// withString:[[notificationName substringToIndex:1] capitalizedString]];
// notificationTitle = [@"View" stringByAppendingString:uppercaseFirstLetter];
notificationTitle = [self notificationTitleUsingNotificationName:notificationName];