o CGPoint , ad esempio. The syntax NSLog(@"%@", ... ); works and is used to obtain information about objects, but does not work on C data types such as struct CGRect or CGPoint , for example. o NSStringFromCGPoint : To take advantage of NSLog(@"%@", ... ); even on C-style structs can rely on conversion functions like NSStringFromCGRect() or NSStringFromCGPoint :
1 2 3 4 5
| CGRect ) { 10 , 20 , 30 , 40 } ; CGRect mioRect = (CGRect) {10, 20, 30, 40}; CGPoint ) { 32 , 64 } ; CGPoint mioPoint = (CGPoint) {32, 64}; / / "Info rettangolo: %@" , NSStringFromCGRect ( mioRect ) ) ; NSLog (@ "Info rectangle:% @", NSStringFromCGRect (mioRect)); "Info point: %@" , NSStringFromCGPoint ( mioPoint ) ) ; NSLog (@ "Info point:% @", NSStringFromCGPoint (mioPoint)); |
Specifically, it is possible to improve this procedure writes of small useful macros like:
1
| # Define NSLogRect (rect) NSLog (@ "% s (% 0.0f,% 0.0f)% 0.0f% 0.0fx", # rect, rect.origin.x, rect.origin.y, rect.size.width , rect.size.height) |
Or:
1 2 3 4
| # Define NSLogCGPoint (point) NSLog (@ "% s (% 0.0f,% 0.0f)", # point.x point, Point.y)
CGPoint ) { 32 , 64 } ; CGPoint mioPoint = (CGPoint) {32, 64}; ; NSLogCGPoint (mioPoint); |
That will give as output:
1
| 32 , 64 ) mioPoint: (32, 64) |
Continued ...
CGRectMake() is a function (actually an inline # define) used a lot especially when you create graphics objects from code or user interface. o UIImageView . CGRectMake() restituisce una struct (struttura di tipo) CGRect : Its use is therefore often associated initialization components of UIKit , but also to simple UIView or UIImageView . CGRectMake() returns a struct (structure type) CGRect :
1 2 3 4 5
| struct {CGRect CGPoint origin; CGSize size; }; typedef struct CGRect CGRect; |
: Which in turn is composed of two different struct CGPoint and CGSize :
1 2 3 4 5 6 7 8 9 10 11 12 13
| struct {CGPoint CGFloat x; CGFloat y; }; typedef struct CGPoint CGPoint;
/ * Sizes. * /
struct {CGSize CGFloat width; CGFloat height; }; typedef struct CGSize CGSize; |
. That, in turn, again, contain types CGFloat or type float . If we analyze the code of CGRectMake () are:
1 2 3 4 5 6 7 8
| CG_INLINE CGRect CGRectMake (CGFloat x, y CGFloat, CGFloat width, height CGFloat) { CGRect rect; y; rect.origin.x = x, y = rect.origin.y; height; rect.size.width = width, height = rect.size.height; return rect; } |
It follows, therefore, that this piece of code:
1 2 3 4
| [ UIButton buttonWithType : UIButtonTypeRoundedRect ] ; UIButton gbutton * = [UIButton buttonWithType: UIButtonTypeRoundedRect]; 12 , 409 , 100 , 40 ) ; gbutton.frame = CGRectMake (12, 409, 100, 40); @ "Press" forState : UIControlStateNormal ] ; [Gbutton setTitle: @ "Press" Forst: UIControlStateNormal]; gbutton ] ; [MainWindow addSubview: gbutton]; |
It could rightly be written as:
1 2 3 4
| [ UIButton buttonWithType : UIButtonTypeRoundedRect ] ; UIButton gbutton * = [UIButton buttonWithType: UIButtonTypeRoundedRect]; CGRect ) { 12 , 409 , 100 , 40 } ; gbutton.frame = (CGRect) {12, 409, 100, 40}; @ "Press" forState : UIControlStateNormal ] ; [Gbutton setTitle: @ "Press" Forst: UIControlStateNormal]; gbutton ] ; [MainWindow addSubview: gbutton]; |
Just to speed things up 'the code is running ... 
Continued ...
Latest Comments
Robert : I rispsoto your questions with pleasure. The idea is really great. I am looking for a solution ...
Sting : @ Darius - you can see an example here: http://www.fight4fun.it/ clicking on: MAPS I hope ...
vik : Giustappunto I'm working on a project and the client asked me to show all the news (which are CPT) in ...
Giovambattista Fazioli : @ paso: absolutely. Simply identifying the field [cci] input [/ cci] you want to ...
paso : Hello I would like to request a service, you can use the datepicker with cform7 I spiegp best I can implement ...