Tuesday, October 16, 2012

objective-c methods; - vs +

So you've been funning around with Objective C and while in Objective C land you've no doubt noticed these little ticks in front of your methods - and others with +

what does it all mean?

While trying to implement a way to find if a string is empty (truly empty, nil (aka null) or filled with whitespaces) I bumped into a neat solution @ http://stackoverflow.com/questions/3436173/nsstring-is-empty
 
+ (BOOL)isEmptyString:(NSString *)string {
// Returns YES if the string is nil or equal to @""
{
// Note that [string length] == 0 can be false 

// when [string // isEqualToString:@""] is true, because these are Unicode strings.

if (((NSNull *) string == [NSNull null]) || (string == nil) ) {
return YES;
}
string = [string stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];

if ([string isEqualToString:@""]) {

return YES;
}

return NO;
}
 

But what sparked up a thought here was that they were using + ClassMethod , and many times while I'm digging around for a solution many are simply -intanceMethods

so what does that mean? One way to think about it, is if I made the above function

an -instance method, then I would call it in my solution like this:

bool boolResult = [self isEmptyString:myStringVariable];


in a +class method
I create a new class (.h and .m files)
in my header:

#import <Foundation/Foundation.h>
@interface NSString (AdditionalStringFunctions)
+ (BOOL)isEmptyString:(NSString *)string;

@end

in my implementation I added the function:
#import "NSString+AdditionalStringFunctions.h"

@implementation NSString (AdditionalStringFunctions)

+ (BOOL) stringIsEmpty:(NSString *) aString {
  
    if ((NSNull *) aString == [NSNull null]) {
        return YES;
    }
  
    if (aString == nil) {
        return YES;
    } else if ([aString length] == 0) {
        return YES;
    } else {
        aString = [aString stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
        if ([aString length] == 0) {
            return YES;
        }
    }
  
    return NO;
}

@end


Now I get to use it like this:

NSString *myString = [[NSString alloc] init];
myString = @"SomeString";

if([NSString stringIsEmpty:myString]) {
   NSLog(@"Your String is empty!");
}
else{
   NSLog(@"Your String is NOT empty!");
 }  


I'll take some time later to look into how to make it be more usable something like:

[myString isStringEmpty]; sort of like the length function

Thursday, October 11, 2012

Manage This!!

You've started developing iPad and iPhone apps for your company for in-house use.  You've managed to check your list and cross it twice,






  • Sign up to Enterprise Licensing at Apple?
       Check

  • Grabbed your Apple ID?
       Double Check
  • Managed to deploy your App to the enteprise?
       Check, Check, Check

  • Can push out updates?
Wait, what?

If you've bought all in to Apple's Eco-System, you can install OSX Server for a few bucks onto an existing MacMini or pre-purchase one already setup that way.  Note that if you plan to first mirror the drives (an option that has to be done manually) I suggest you DO NOT setup profile manager 2 as it's a little tempermental when things don't point just right...

Once your disk setup is ready (mirrored or not) follow the advice at this blog link to help your self to a step by step guide on how to setup your MDM server.

 the only note to make here is that the  terminal command : sudo changeip -checkhostname did not work for me, so just an FYI...

http://krypted.com/iphone/configuring-using-profile-manager-2-in-os-x-mountain-lion-server/


You can always go with a third party MDM server but those will be far more expensive and for small deployments you really can't go wrong with Apple's solution. 

Friday, July 20, 2012

Getting started with iOS programming

So you got the mobile bug?  There are so many developers still jumping on the iOS bandwagon.  I'm a Sql guy, and as one my biggest strengths have been from leverging languages like VB, vbscript and TSQL.  So when I set forth to learn how to write an iOS application, it was daunting to see just how many resources there were all over the internet.  

so much help, but none of it was for me!

I eventually began to get frustrated, because even though there was a mountain of information I found myself thinking "Wow!, there is so much help, but none of it was for me!" Like so many people I went online to youtube and such sites hoping to get a sort of feel for the language, the IDE, but more importantly, inside the mind of an Objective-C coder. I signed up for the developer account on Apple's website and found myself again, lost in the developer forums reading up on what was another language that might as well had been written by aliens, because, initially I was very overwhelmedI took my classic approach.  I thought of something I wanted to accomplish in the language of choice and set forth to discover just how easy, and complicated my solution would be.  With my collection of web bookmarks, favorite books and video sites, I hope to provide a useful blog of information.

Welcome to my blog, the purpose here will be to enable me to create a breadcrumb list of shortcuts, how-to's for my specific problems.  The goal (like my SqlThis blog) is to write it generically enough as to provide a useful springboard for many visitors.

In this post I will link the helpful books that got me started along with some awesome online tutorial sites

Thursday, July 19, 2012

Shortcut to...

I'll return and expand on each, first siting the tutorial, then adding any editorial needed for my purposes :) (some of these links though are perfect!)
so your keyboard is hiding your uitextfield?


Need to download that stream down to disk so as to not overconsume all your ram?

Barcode it right with ZBar (opensource barcoding)