Friday, June 1, 2012

Don’t miss these cool stuff in D10

Tim Cook talked about Apple

See the video here: Tim Cook on Steve Jobs , Apple TV and Facebook: The D10 highlights

Mary Meeker release Internet trends of 2012

See this 98 pages report:

KPCB Internet Trends – 2012



Via Tonny Xu http://feedproxy.google.com/~r/tonnyxu/~3/KFKbY6I7xPs/ Social, Something really cool!

Wednesday, May 23, 2012

An excellent handbook: “Facebook for business” from Looops.net

Looops.net released an excellent facebook handbook for business. This is such a good handbook, I’d like to share this in my blog.

The handbook was written in Japanese. Hope you can read it.

Although it was written in September 2011, but it still has huge value for anyone who want to apply Facebook to their business.

Meanwhile, my colleague Yazawa Osamu and his company Socialand is also pioneer on helping business user to expand their business on Facebook.

handbook on Slidershare



Via Tonny Xu http://feedproxy.google.com/~r/tonnyxu/~3/IMAO7zpi6HM/ Social, Something really cool!

Tuesday, May 22, 2012

WWDC2012 eve @Tokyo

WWDC 2012 will be open within 3 weeks, I’d like to have a WWDC2012 eve party at my company Voyage Group. iOS developers who can go WWDC from Tokyo, if you have time on Friday, June 1st evening, please come!

How to register

Please visit: ATND and register yourself.

Fee

2000Yen/person

includes: * Free beer/Free softdrink * Free Pizza/Sushi

Date and time

June 1st, 2012 7pm~10pm

Place

AJITO of Voyage Group 〒150-0045 8F 8-16 Shinsen-cho Shibuya-ku, Tokyo

Topics

  • Making new friends
  • Exchanging hotel/tour/visit information, etc.

OK, let’s meet up on June 1st, at 7:00pm



Via Tonny Xu http://feedproxy.google.com/~r/tonnyxu/~3/WEXj9hK5dBE/ iPhone Dev, Something really cool!

Saturday, May 12, 2012

An object in Cocoa, but do not use `*`?

Block

via NedraI via CC License

A funny question

Here is the funny question:

Is there any object in Cocoa/Objective-C that is a object but you do not use * to indicate it?

Now, think a few seconds before you read on: is there any such kind of objects?

NO? are you sure about that?

The Answer

The answer is YES! Yeah, there is a such kind of object in Cocoa/Objective-C.

It is the Block object!

Why?

Apple brought Block, a much more common name is Closure. As you can see from the wiki page, it is a non-standard extention to C/C++/Objective-C 2.0

Because it is an extension not only to Objective-C, but also to C/C++, so it has some special treatment.

Because Block has ^

To indicate a piece of code as a Block(or a Closure), it DOES need something like a pointer, but not a normal pointer. It act as a function pointer, but much more powerful.

So Apple introduced ^ as a replacement of * to Block.

In Objective-C ^ == *

As we can see, ^ is also a pointer, so why do we need another * to pointer to a Block?

Sample code

Use it as a method argument

  typedef void (^MyBlock)(void);  - (void)doSomethingWith:(MyBlock)block;    

Use it as a property

  typedef void (^YourBlock)(void);  @property (nonatomic, copy) YourBlock block;    

Use it as a function argument

  typedef void (^HisBlock)(void);  void myfunction(HisBlock block);    

Note that, none of above is using * to indicate a block, because the typedef has already indicated it is an object.


Of course, don’t forget to follow me @TonnyXu and Facebook



Via Tonny Xu http://feedproxy.google.com/~r/tonnyxu/~3/8TGoxRpWNAU/ iPhone Dev

A Quick and Clean Way to Test Your HTTP GET and POST request

POST

photo via Corey Templeton via CC License

Well, this post is simple, HTTP POST is relatively complex than HTTP GET, some times you want to do a quick test with your post data.

Here are the solutions I know. If you have any other solutions, let me know.

A Free POST Only Test Sever

Access: http://www.posttestserver.com/post.php. This will dump all the http data for you. A good/bad approach of this site I like is that this site will record your request and you can review your request later. But we are not always just want to view the data in web page, sometimes, we also want to use it in unit test.

For example I had posted a request and your can see it here: http://www.posttestserver.com/data/2012/05/11/00.24.01738126829

It’s a test from an iOS App I recently work on.

The Ultimate Solution for Testing HTTP Request

http://httpbin.org/

This is the BEST site I know for test HTTP request. As it listed on the home page, there many test endpoint:

ENDPOINTS

/ This page.
/ip Returns Origin IP.
/user-agent Returns user-agent.
/headers Returns header dict.
/get Returns GET data.
/post Returns POST data.
/put Returns PUT data.
/delete Returns DELETE data.
/gzip Returns gzip-encoded data.
/status/:code Returns given HTTP Status code.
/response-headers?key=val Returns given response headers.
/redirect/:n 302 Redirects n times.
/relative-redirect/:n 302 Relative redirects n times.
/cookies Returns cookie data.
/cookies/set/:name/:value Sets a simple cookie.
/basic-auth/:user/:passwd Challenges HTTPBasic Auth.
/hidden-basic-auth/:user/:passwd 404′d BasicAuth.
/digest-auth/:qop/:user/:passwd Challenges HTTP Digest Auth.
/stream/:n Streams n–100 lines.
/delay/:n Delays responding for n–10 seconds.

This site is really awesome! Just try it!

Any suggestion?

If you have any suggestion or better solutions, please leave a comment.


Of course, don’t forget to follow me @TonnyXu and Facebook



Via Tonny Xu http://feedproxy.google.com/~r/tonnyxu/~3/woj9p1nMg6s/ iPhone Dev

Wednesday, April 4, 2012

Think different

ThinkDifferent-Original

Good things are always inspirational, this ad not only inspired a lot of Appler, but also encouraged me to do what I want to do.

Many thanks to Steve Jobs. I will always miss you.

The scripts

Here’s to the crazy ones. The misfits. The rebels. The troublemakers. The round pegs in the square holes. The ones who see things differently.

They’re not fond of rules. And they have no respect for the status quo.

You can quote them, disagree with them, glorify or vilify them. About the only thing you can’t do is ignore them. Because they change things. They push the human race forward.

While some may see them as the crazy ones, we see genius. Because the people who are crazy enough to think they can change the world, are the ones who do.

The video

Think different(HD)

The icon of TextEdit.app



Via Tonny Xu http://feedproxy.google.com/~r/tonnyxu/~3/n7eWwaXnJio/ Something really cool!

Monday, April 2, 2012

Make the UITableView with group style to round the image.

The point is, the roundCorner is draw by a subview of UITableViewCell, and mean while, it’s not a public class, there is no way you can get layer.cornerRadius from any view. So we need to resolve this problem by ourselves.

There are 2 cases.

  1. There is only one cell.

    This case is ease, just use cell.contentView.layer.cornerRadius and cell.contentView.layer.masksToBounds to make it work.

  2. There are more than one cell.

    This case is a little bit difficult. We need to deal each cell separately. Use the cell.contentView.layer.mask property to make it work. The first cell and the last cell has different round corner position. So draw the path and make it work.



Via Tonny Xu http://feedproxy.google.com/~r/tonnyxu/~3/K05PnoAt1yo/ iPhone Dev, Programming, Tips

Which direction is `UIImageOrientationUp`

UIImage has a good property named imageOrientation, all the images taken by iPhone/iPad is stored in physical orientation, when draw it on the view, most of the UIKit API and CoreGraphic API can recognize the orientation and render it it correct orientation. But if you need to resize the image or do some effect on the image by yourself, you need to calculate the image orientation by yourself. Thus you MUST understand which direction is UIImageOrientationUp.

The possible orientations

The UIImage header file defined the orientations as:

 typedef enum {     UIImageOrientationUp,            // default orientation     UIImageOrientationDown,          // 180 deg rotation     UIImageOrientationLeft,          // 90 deg CCW     UIImageOrientationRight,         // 90 deg CW     UIImageOrientationUpMirrored,    // as above but image mirrored along other axis. horizontal flip     UIImageOrientationDownMirrored,  // horizontal flip     UIImageOrientationLeftMirrored,  // vertical flip     UIImageOrientationRightMirrored, // vertical flip } UIImageOrientation;  

Fine, it is commented, but, hmm, no so well. Could you tell me which direction is the UIImageOrientationUp?

The UP orientation

It’s not the orientation when you hold your iPhone in the normal mode. Make a guess!

OK, I know your guys are not so patient, so,

Here is the correct answer: this orientation is the UP!

The UP orientation when you take a photo on iPhone



Via Tonny Xu http://feedproxy.google.com/~r/tonnyxu/~3/RkjWuse3NYI/ iPhone Dev, Tips

Use `DEPRECATED_ATTRIBUTE` to clean up your code

What is DEPRECATED_ATTRIBUTE

Actually, DEPRECATED_ATTRIBUTE is a macro, it is defined as:

 /*  * only certain compilers support __attribute__((deprecated))  */ #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))     #define DEPRECATED_ATTRIBUTE __attribute__((deprecated)) #else     #define DEPRECATED_ATTRIBUTE 

Tuesday, March 27, 2012

How to integrate MVC pattern with GCD/KVO/CoreData in iOS

My publication

Last year, I published this article on Software Design Issue November. The whole article was written in Japanese. Since I’m not a native Japanese, I’d like to thank my fellow coworkers Nagano/7gano and Kato/guruguruman to help me review the article again and again. Without your help, I could not make this happen.

View the content

The Japanese title of this article is iOS でのMVCパターンの再検討およびCore Data、GCD、KVOの実践運用

The article was coordinated with Gihyo‘s format and it’s hard to layout it again, so, I’d like to share the finished page in PDF with everyone.

View the article in PDF

Brief content in English

  • CoreData is powerful, and if you don’t have legacy database to conform to, use it
  • KVO is super powerful, but come with side effect. It can help you with your multiple UI update, and can also mess your code flow
  • GCD is awesome! forget about delegate, use GCD whenever possible with multithread programming
  • All these technologies comes great with MVC pattern

Finally, as always, follow me on Twitter or Facebook



Via Tonny Xu http://feedproxy.google.com/~r/tonnyxu/~3/ee83fUHCzx0/ iPhone Dev