Articles Tagged 'define'

How to develop in PHP with Xcode and Objective-C

How many programmers to use, I also build my own library of functions ready to be reused in multiple projects and multiple contexts. Let me change the title of this post, maybe a little 'risky but, nevertheless, as we shall see, not far from reality.

In Objective-C you can write and call C / C + +, including the assembly for that matter. This characteristic makes it a very versatile language and, in some respects, phenomenal. On the one hand, you can use and appreciate the purely syntax of Objective-C, on the other you can run faster porting code written in ANSI C (perhaps for Digital Unix or Sun) and can comfortably fit into our iPhone or iPad applications; not to mention all the BSD kernel is already available on Mac OS X!

Continued ...

How to delete NSLog () from source XCode

<a target="_blank" href="http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#//apple_ref/c/func/NSLog">NSLog()</a> a useful function during the early stages of a project for testing and debugging an application for Apple iPhone or, more generally, in the XCode environment. Being just a function, just like the other, his presence will be felt even when releasing (release) our executable. potrebbero influire sulle performance della nostra applicazione, soprattutto se abbiamo inserito NSLog() all'interno di loop. It then becomes necessary to remove, in some way, all the rows in NSLog() out of our code, because it is no longer needed, and because calls to NSLog() could affect the performance of our application, especially if we put NSLog() to 'inner loop.

Immediately rule out the solution to the "look" and "cancel" because one day there could be used again. We exclude the solution of the "look" and "comments", uncomfortable for the same reason as before. Fortunately, a clean, simple, and are using the correct compiler conditionals. What we will do in practice, and tell the compiler to exclude - if there is a specific condition - when compiling our source lines that contain NSLog() .

The compiler directives and compiler conditional statements, are a very powerful and widespread. Those coming from the development of the ANSI-C knows very well and will definitely utilizzte in many situations. The peculiarity of these "instructions" lies in the fact, mentioned above, to be seen by the compiler and not executable. This feature makes them useful in many cases and can solve problems otherwise very annoying.

Let's see an example of code that, as predicted, you can "delete" from the compilation of code share, in our case NSLog() :

1
2
3
4
5
6
# Define ACTIVE_NSLOG 1
/ / If the constant is defined ACTIVE_NSLOG fill
/ / The block of code between # ifdef and # endif
# Ifdef ACTIVE_NSLOG
" ... bla bla" ) ; NSLog (@ "... blah blah");
# Endif

). Conditional statements are part of the compiler of the same family as #define , also, in fact, are preceded by a "pound" ( # ). solo se ACTIVE_NSLOG è definito. In the example shown we have defined a constant ACTIVE_NSLOG ; subsequent lines of code tells the compiler to "include" line NSLog() only if ACTIVE_NSLOG is defined. If we took care, during the writing of our code, to place calls to NSLog() within the block #ifdef ... #endif per far sparire, alla prossima compilazione, tutti i nostri NSLog() . #ifdef ... #endif , just delete the definition of the constant ACTIVE_NSLOG to disappear, the next compilation, all our NSLog() .

A best and final

Let us now see how to set the XCode environment to improve even more what we have done here! First of all we choose a constant name that we use in our projects to exclude from the compilation NSLog() . o quello che preferite. You can choose the name that you like, from DEBUG to MIO_DEBUG or whatever you prefer. Open your project, new or old. Enter all the NSLog() within the block (or block):

1
2
3
# Ifdef MIO_DEBUG
" ... bla bla" ) ; NSLog (@ "... blah blah");
# Endif

Select the main file of your project, click the right button and choose the Get Info item.

getinfo

This opens the window with information about the project:

userdefine

Select the Build tab, verify that you are in the Debug configuration (this is the gem), go to the User-Defined section and add, via the button at the bottom left, a new field called OTHER_CFLAGS . At this value assegnamoli -DMIO_DEBUG=1 . The syntax is -D{mia define}=1 .

This procedure has two advantages:

  1. We must not put in the code #define MIO_DEBUG 1 , but we do it through the project information. So, when we go to fill out the release version (the one without the NSLog() ) do not have to remember to delete the line #define MIO_DEBUG 1
  2. The constant is defined in relation to the configuration, in our case Debug. So, switching to Release configuration (release) will be absent and the constant rows with NSLog() will not be compiled

Conclusions

The above procedure may be useful in a moltidutine other cases, with NSLog() , have nothing to do. Conditional statements can help the compiler in a wide range of contexts. They are often used by programmers to determine the type of operating system, version, the target, the presence of mathematical processors, while maintaining the same "same" source.

To understand, as an example, we can utilizzre our constant MIO_DEBUG also intervene in other areas of the code:

1
2
3
4
5
6
7
8
9
10
/ / Debug if they win the game
/ / With a score of 100 instead of 10000:)
# Ifdef MIO_DEBUG
score == 100 ) if (score == 100)
# Else
score == 10000 ) if (score == 10000)
# Endif
{
; [HaiVinto self];
}

To finish, here are some examples and variants:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/ / In general there is
# If expression
/ / If statement similar to the traditional, so with a full expression

/ / Check if a constant is defined
# Ifdef constant

/ / Check if it is NOT a constant defined
# Ifndef constant

/ / Else
# Else

/ / Close the block
# Endif
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/ / For example ...
# Define DEBUG 1
5 # define MIA_ALTRA_COSTANTE

...
# If DEBUG
/ / Fill in this
# Else
/ / Otherwise fill this other
# Endif

# If MIA_ALTRA_COSTANTE> 4
"..." ) ; NSLog (@ "...");
# Endif
1
2
3
4
# Ifndef INCLUDE_MIO_FILE
# Define INCLUDE_MIO_FILE
# Include "mio_file.h"
# Endif

Continued ...

WordPress: revision management and dell'autosave

. The new features of WordPress revisions can be controlled and set via define global WP_POST_REVISION . Its definition can be inserted in the file wp-config.php :

Continued ...

10 reasons to upgrade to Adobe Flash CS3

2007-11-21_170314 For some developers just need to know that there is a new version of their preferred development package to run and buy the upgrade. Others, quite rightly, more calm and maintain a "pretend" to know the actual improvement in the new version before you change your habits. In the case of Adobe Flash CS3 is not much to wait, given the many changes that the package has undergone since Macromedia was acquired by Adobe.
Here, then, 10 simple, but important, reasons which, in my personal opinion, enough to convince you to upgrade to Adobe Flash CS3 . I will focus, of course, only on the things that struck me personally, this is not intended as an exhaustive list of all the many innovations introduced by the CS3 suite, only a fly to anticipate some features of CS3.

1. Installation

The installation is nice and fast, compared to previous versions. It includes, among other things, with all Adobe products (Dreamweaver CS3, Photoshop CS3 Extended, etc ...) which makes the installation / removal, and update a real pleasure.

2. Backward Compatibility

One issue often overlooked, but always taken into account in the history of Flash: The ability to manage previous versions of the product. In Flash CS3 has all the tools to manipulate it is to migrate the previous versions of our movies. We find this possibility in debugging (debugging a separate Actionscript 2.0 and Actionscript 3.0) is in the process of completing the movie. Write now Actionscript 3.0 Flash applications could be counterproductive in certain contexts. If your target site has a high traffic you may find that many users have not yet installed the latest versions of Flash Player for your browser and then would not see the movie. However, as noted above, Flash CS3 allows you to develop Flash applications mantendedo backward compatibility and therefore I do not see this as a big ostocalo nell'upgrade product.

3. GUI and IDE

Panel minimizedFlash CS3 New Panel The IDE Flash CS3 (like Dreamweaver CS3) has been revised to better. The panels (see picture left), often uncomfortable in previous versions, have been completely redesigned and now their use is much less invasive. Panels in icon mode In addition, the ability to minimize panels (see figure at right) is found that makes a real attractive and functional interface. When a panel is in icon mode takes up much less space and with a simple click you can open the first main panel always visible.
All the IDE, in short, has been revised including the central area with the window for editing and graphic code. Do not you point out all the changes or you'll ruin the surprise ...

New Flash CS3 IDE

Continued ...