Showing posts from December, 2013

A hint for when you are setting up the Android SDK on IntelliJ IDEA

​When trying to set up an Android SDK, you might be presented with the following error: "the selected directory is not a valid home for sdk" Just make sure that you are running IntelliJ as an Administrator. The other thing to check for is if one of the folders in the path is hidden, which can happen if you selected to only install the Android SDK for the current user. Just unhide the folder. (A Windows specific issue) This might also be applicable to Android Studio, I'm not sure. There ya go :)

Comparing NSDecimalNumbers in Objective-C

​So ran into this issue when checking if an NSDecimalNumber variable is less than zero: if(myNSDecimalNumberVariable < 0) {        <the then code block> } else {        <the else code block> } and it was always going to the else, regardless of the value of my variable. Apparently what is happening is that pointer addresses are being compared. If I was comparing two NSDecimalNumbers I would have similar "strange" behaviour. I'm guessing to someone who grew up on a language familiar with pointers, that this would have been obvious. However, I was not that fortunate. The correct way to do a comparison is to use the "compare" instance method: if([myNSDecimalNumberVariable compare:[NSDecimalNumber zero]] == NSOrderedDescending) ....<the rest of if statement> This is something to keep in mind with a lot of the Objective-C types. Dave at  innerexception  showed me the light...

Querying an NSSet from CoreData

So... for entities that have a to-many relationship you get an NSSet property. When querying this property you can use the ANY and ALL operators. Scenario: {     You have entity A that has a to-many relationship with entity B.     Entity B has two rows. One having a property that is set to FALSE, the second row has that same property set to TRUE.     Entity A has two rows. The first having a link to the FALSE row, the second having a link to both TRUE & FALSE rows. } Selecting rows from entity A where "ANY" of the rows from entity B has the property set to FALSE, will return both rows. Selecting rows from entity A where "ALL" of the rows from entity B has the property set to FALSE, will return only row one from entity A. As this is the only row where ALL the links are FALSE. THE PROBLEM: The "ALL" operator doesn't work! It will crash your application. You will get the following error: Terminating app due to uncaught exception 'N

Tracking service call durations and times on Fiddler

Here's some scripts for custom columns that I use on a daily basis. Helps me a lot to keep track of when webservice calls were made and how long they took: This method gives you a column with the duration of a web call, formatted into a time:        public static BindUIColumn ( "Duration" )        function CalcDurationCol (oS : Session )           {               var sResult = String .Empty ;               if ((oS .Timers .ServerDoneResponse > oS .Timers .ClientDoneRequest ))               {                      sResult = String .Format ( "{0:H:mm:ssss.ffff}" , (oS .Timers .ServerDoneResponse - oS .Timers .ClientDoneRequest ));               }               return sResult ;        } This method gives you a column with the time that the request was started:        public static BindUIColumn ( "RequestTime" )        function CalcRequestTimeCol (oS : Session ){               if ( null != oS .oRequest )                     

Searching for resources in XCode

Unfortunately you can't search for resources used in XCode, it sucks. If you are using AppCode you do not have this problem. Example: images used in .xib files won't be found in search. One would think that this very basic and common task that should be easy to do. Not. Using the Search Navigator would only give you results in the .h & .m files. But, what about references in a xib/storyboard/plist etc? To get around this, open terminal and use this nifty grep command  (add whatever extensions you want to search for in the curly brackets) : grep -i -r --include=*.{xib,m,h} "filenamewithoutextention" /the/location/to/search/in

Super Awesome Secret Emulator Tip: How to enable your computer's keyboard on the Windows Phone emulator

All other emulators allow you to type in using your PC's keyboard, right off the bat. Apparently there's a super (and very, very) secret way to get your keyboard to work for the Windows Phone emulator. Press the Pause/Break key on your keyboard.   It will toggle between using the emulator’s on-screen keyboard, and your physical one. Who knew?... Accidentally stumbled upon this after years of working with the emulator:  jeffblankenburg (Many thanks to this guy)