Hi nerdz,
today i’ll show you how to easily control remotely your room with a stupid motion detector, a piro sensor (or you can use other sensors, like ultrasonic, infrared, light sensor, pressure, etc etc…) and two lines of PHP code and C.
* Useful if you want to know if anyone enter in your room and the time that remains there! *


You can get this sensor from AirWick deo! ![]()


How it works?
Your piro sensor, when detect a motion, notify arduino, that was programmed to send to serial port a value (“m” or “n”).
These value are interpreted by a serial reader (c# program, objective-c, java, c++, or somethig else) that call a PHP page that send email if is enabled sending mode.
Second php page, permit you to control arduino (enable/disable/show logs/clear all).
Steps:
Connect your piro sensor to arduino, easy way, like this:

After that, write your simple arduino code:
Hi all!
By chance i founded this tricks that permit to show a “Dictionary definition” for the selected word in a UITextField on a hidden menu.
Menu contains these actions:
It’s a cool tricks, that show an hidden menu with a lot of options, that i never see before!
Watch this:



And this is the dictionary definition for pizza on simulator:

How?
Continue reading “[Objective-C] Show dictionary definition on UITextField” »
Follow these simple steps, and after 1 minutes you’ll print your code generated pdf from your iphone!
Remember that CoreText.framework works only with iOS >= 3.2 for ipad and iphone 4.0.
1 2 3 4 5 6 7 8 | + (void) drawPDF:(NSString*)fileName; + (void) drawLabels; + (void) drawText; + (void) drawText:(NSString*)textToDraw inFrame:(CGRect)frameRect; + (void) drawLineFromPoint:(CGPoint)from toPoint:(CGPoint)to; + (void) drawLogo; + (void) drawImage:(UIImage*)image inRect:(CGRect)rect; |
Now, implement all methods in your class…
Continue reading “[Objective-C] Print code generated PDF with AirPrint” »
Suppose that we have a ViewController.h and .m like this:
1 2 3 4 5 | // ViewController.h #import UIKit/UIKit.h @interface ViewController : UIViewController @end |
1 2 3 4 5 6 7 8 9 10 11 12 | // ViewController.m #import "ViewController.h" #import "SetValue.h" @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; [SetValue SetTheValue:@"a string"]; } @end |
And a class called SetValue, with two methods.
1 2 3 4 5 6 7 8 9 | // SetValue.h #import Foundation/Foundation.h @interface SetValue : NSObject { } + (void) SetTheValue:(id)Obj; - (void) MySelector:(id)Obj; @end |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | // SetValue.m #import "SetValue.h" @implementation SetValue + (void) SetTheValue:(id)Obj { [self performSelectorOnMainThread:@selector(MySelector:) withObject:Obj waitUntilDone:NO]; } - (void) MySelector:(id)Obj { NSLog(@"Data: %@", [Obj description]); } @end |
What is the value printed by the NSLog?
enjoy.
Ref: albertopasca.it
NSString and retainCount memo:
1 2 3 4 5 6 7 8 | NSString *A = [[NSString alloc] init]; NSLog(@"_A_RC: %i", [A retainCount]); NSString *B = [[NSString alloc] initWithFormat:@"AAA"]; NSLog(@"_B_RC: %i", [B retainCount]); NSString *C = [[NSString alloc] initWithString:@"AAA"]; NSLog(@"_C_RC: %i", [C retainCount]); |
1 2 3 | ...Test[3530:15203] _A_RC: -1 (ios < 5 = 2147483647) ...Test[3530:15203] _B_RC: 1 ...Test[3530:15203] _C_RC: -1 (ios < 5 = 2147483647) |
Because your string is not in the heap, but is a constant. A NSString made from a constant NSString is identical to the original NSString.
UINT_MAX (2147483647) -> http://it.wikipedia.org/wiki/2147483647
Ref: albertopasca.it




