Skip to main content

Posts

Removing NSLogs from release build

NSLogs are great when debugging to see exactly what is going on but the downside is that they impact heavily on performance (I speak from experience on that one). Luckily there is a way to "disable" them on release builds of your application and still have them in your debug builds. we do this by simply adding the following macro to the prefix .pch file in your project or anywhere before the entry point to your application. #ifdef DEBUG #define NSLog(...) NSLog(__VA_ARGS__) #else #define NSLog(...) {} #endif If you want an explanation here it is. When you build a Debug version of an application DEBUG is defined , if its a release build , DEBUG is not defined.This macro checks if DEBUG is defined , if it is it sets NSLog to what it should be , if DEBUG is not defined then NSLog is defined as an empty code block that as you should know will do nothing , thus saving on performance.

Color status bar on iPhone

This is just a quick tip with some basic logic on how to get a colored status bar on an iphone app ,here i will be assuming that the app does not rotate so i will be placing all the code in appdelegate in the - ( BOOL )application:( UIApplication  *)application didFinishLaunchingWithOptions:( NSDictionary  *)launchOptions So the secret is really that there is no secret ,apples framework does not allow you to choose the color of the status bar so instead we set the status bar to the translucent  predefined style of  UIStatusBarStyleBlackTranslucent  and then we draw a colored view behind it to make it appear as though the color of the bar has changed. Here is a sample where i "tinted" the statusbar cyan in the app delegate : - ( BOOL )application:( UIApplication  *)application didFinishLaunchingWithOptions:( NSDictionary  *)launchOptions {         [[ UIApplication   ...

Using delegates in Objective-C

Why use delegation? Well when writing Objective-C programs in Xcode we are encouraged to use the MVC(Model View Controller) structure.In MVC a model cannot send messages directly to a specific controller.This can become a problem if data in your model changes independantly and you need to update this information in your view via the controller(The model must never communicate directly with the view).This is where a delegate comes in,it allows messages to be sent from the model to a controller that is not specified in the model but is rather specified by the controller,in other words the controller specifies itself. If you dont really understand what im talking about so far ,don't worry.I didn't understand delegates either until I needed one,but hopefully by the end of this tutorial you will understand not only how to use a delegate ,but the reason you would want to use one. Program breakdown For this tutorial we will write a program that has a model that will change an...

Lion's eat RAM's

I recently purchased a Mac-mini(Yes I own a Mac now) with relatively the same hardware specs as my(well the one I work with) MacBook pro, Intel Core i5,Graphics 3000(or whatever) etc. The only difference being that the ram in the Mini was only 2GB and the Laptop has 4GB,we will come back to this later. The MacBook Pro experience: My experience with the laptop has been great,never lagging and I really got used to using a track-pad instead of a mouse and found gestures very helpful for quick desktop management with a small screen.It was also very responsive and I keep tons of windows open all the time without problems.  When I got my Mac Mini,I popped it out of its box and plugged it in to my standard PC peripherals,switched it on and everything worked fine ,I got a few nice surprises too,I did not expect it to come with a wireless card or built in Bluetooth,just like it does on the MacBook. Then I tried to run Safari,iTunes and Xcode all at once(I do this often while worki...

The World’s best operating system

This is a debate that has waged since the beginning of the three major operating systems, namely Microsoft Windows, The Mac Operating system and the many variations of Linux. For the purpose of this post I will be comparing using the latest versions, so that is Microsoft Windows 7, Mac OSX Lion and well, Linux is Linux. Microsoft Windows is the operating system everybody should be familiar with, it’s pretty much what people grow up with and become used to, when you buy a pc, it more than likely comes with windows, you don’t get pc games, you get “games for windows”, plus the average person’s question when they see Linux on your pc is “What windows is that?”. Up until now though, I have never been happy with windows, there were always error messages and viruses and just general slowness and inefficiency. But from the moment I saw windows 7, I liked it, not only did it look good, but it performed well and I was able to use it for months without a single error, I nicknamed it Windo...

Skyrim

Out of all the games I was anticipating in 2011, The Elder Scrolls: Skyrim  (Kelle: Keizaal in the Dragon tounge) was strangely not one of them.This was because I hated Oblivion and expected Skyrim to be the same.  I was very,very wrong. There were actually only two reasons I hated Oblivion, but they deterred me from actually attempting to finish the game.Reason one was that the inventory used illogical little icons and was as intuitive as Quantum mechanics(I to this day don't know how to drop an item in Oblivion) .Reason two was aesthetics,the people are the ugliest collection of creatures ive seen in a game,and thats just the humans... And then theres the water,lets just say it filled my head with strange thoughts of water coolers in the Bethesda office being filled with a strange matte blue liquid. In Skyrim they fixed it all ,everything is beautiful ,and finally someone got it into thier head that words are alot more intuitive than silly little pictures (they even ...

Using The AeroGlass library

AeroGlass Library Version 1.2 Contents: ·          Usage with Windows forms ·          Usage with WPF forms The AeroGlass library accesses the dwmapidll to extend the frames of windows for use with the C# language, this gives the effect of having more glass areas on a window or making a window look as if it is completely glass. The library aims to make implementing this method easier so that you can achieve this effect with minimal code and will not have to access the dll yourself,version 1.2 of the library is compatible with both windows forms and WPF forms, though the implementation differs slightly. This documentation covers the implementations of both types. Usage with windows forms There are 2 ways of implementing glass on a Windows form using the AeroGlass library, one is to use the GlassPane controls AutoExtend property and the other is to use code, let us first take a...

My C# 2D Game

A couple of months ago i started writing a 2D shooter game using OpenTK(The Open Tool Kit) in C#,i got far but I ran into some issues,that ,due to my lack of knowledge and experience with the language caused be to abandon the project.I recently picked up the project again and in three days I was able to rewrite the game to the point at which I last stopped(this originally took me months),and the code is much more efficient. Luckily I have found ways to overcome certain problems and even though the collision checking is slightly dodgy it is now a simple working game that loads levels from a level file format I developed myself.It is my hope to soon release a "bemo'" so that people can see what I'm doing and I can maybe get some feedback.I use the term "bemo" to refer to a beta-demo containing only a few levels ,like a demo,but using the beta game code. So far the level files can only be produced by typing them out,I am working on documentation for the ...

MacBook Pro with Lion,WiFi problems?

If you don't know already I am a fan of Apples products,this is coupled with a strange fact.I have never,ever owned anything made by Apple besides the copy of Snowleopard I run on a VirtualBox. I may not own one ,but I think I can speak with authority on the topic of "MacBook Pro with Lion,WiFi problems?" because of what I have seen on another machine and what I have Internet-ed. I have seen Lion run on a 2008 15 inch MacBook Pro - no WiFi problems ,why? It was fully updated.The reason I am actually posting this is that I recently tried helping someone with this problem on a not fully updated MacBook Pro(hence the extensive internet research).Of all the strange hacks and ideas the only eureka moments on the internet are when some guy posts ,"I updated and now it works". So there,if you are having WiFi problems on your MacBook pro with Lion,Update,it seems like it works and it makes more sense than "8.8.8.8". The person I attempted to help ...

Setting up Qt Creator for assembly

After fiddling with inline asssembly (not very successfully) ,I recently decided to try writing proper assembly and compiling with NASM in Linux. After writing a hello world using gedit and having a terminal open for compiling,linking and running I had a thought.,there has to be a better way to do this. So I tried Qt Creator ,because I know it's easy to add custom build and run commands,and what do you know? I got it to work. Here's how,my screenshots and assembly code are in Linux but the set up should be the same regardless of the operating system,if you are not using Linux then just use the same commands you use to assemble in your operating system. First off ,create a new console application: I named mine ASM Rename the main.cpp to main.asm and delete all the text inside.then insert some assembly: Now open up the “Project” tab and edit the build settings,remove the current build and clean steps and remove the “-build-desktop” from the en...

Need I say more?

  Ok ok I will say more,for those of you who don't already know,Tux(the penguin) is the Linux mascot,and the robot represents Microsoft's Windows. If you want to know more about Linux there is a link to Wikipedia here . If you want to try it out ,here is a link to the most popular distribution: http://www.ubuntu.com/

Prettyfying with CSS

The internet is filled with tutorials on how to do nice effects with CSS,so I decided to fill it more by doing a tutorial on 3 effects: Rounded corners,Shadows and gradients. At the end I will show you an example of what can be done when you string these 3 together. WARNING: A lot of this stuff may not work in Older browsers,if your browser does not support these styles ,the following link may help http://www.mozilla.org/ . If you need to see the pictures below more clearly,click them. First off ,lets create two files one html file and one CSS file hello.html and style.css. Lets start with setting up the CSS so we can get a nice layout. body { font-family:Arial; background-attachment:fixed; width:800px; margin:5px auto; background-color:#696969; font: normal 10pt Arial,Helvetica,sans-serif; } #pageDiv { background-color:#ffffff; padding:3px; } Then set up the html file. <html> <link rel="stylesheet" href=...

Rapid Firefox

Sometimes in the tech world you get this feeling that you are slightly behind,like not all of your programs are up to date and they may be a year or two old. Lately though some programs have updates that  are so regular that if your program was up to date a couple of hours ago ,it isn't any more. Firefox is one of those programs,in fact it has the tiniest release intervals ive ever seen,I think it should be renamed.Maybe something like Tasmanian Devil(with a jetpack). I'm not complaining about this ,Frequent updates are a good thing ,I'm just suggesting some more appropriate naming."Rapid release" just doesn't do Firefox's bewildering update release speed justice.Its kind of like describing the way a minigun fires its rounds as "rapid release". It just sounds wrong.Come to think of it "rapid fire" would be a better way to describe things than "rapid release" (for both Firefox and the minigun). At leas...

FIRST

Well well ,my first blog ,and about time too, my nerd progress has been slow thanks to the limited Internet in lovely South Africa. As the title should tell you (I hope it does,I'm such a noob) ,this blog is about me,a Student/Programmer.The blog will be mainly aimed at programming and tech subjects and events that affect me /etc/. One thing you should know is that I am a fan of both Apple and Linux.I don't own anything made by Apple but I would really like to. I also Have a project on source-forge: https://sourceforge.net/projects/qpigz/ I look forward to posting more stuff and hopefully being more interesting than I am being now,probably because its 2:27 in the morning...