Tag Archives: Iphone

Google Objective-C coding standard

I am not sure what coding standard you follow, but I usually follow the Objective-C coding standard of Google for code formatting:

Spacing And Formatting

Spaces vs. Tabs

Use only spaces, and indent 2 spaces at a time.
Line Length

Each line of text in your code should try to be at most 80 characters long.
Method Declarations and Definitions

One space should be used between the - or + and the return type, and no spacing in the parameter list except between parameters.
Method Invocations

Method invocations should be formatted much like method declarations. When there’s a choice of formatting styles, follow the convention already used in a given source file.
@public and @private

The @public and @private access modifiers should be indented by 1 space.
Exceptions

Format exceptions with each @ label on its own line and a space between the @ label and the opening brace ({), as well as between the @catch and the caught object declaration.
Protocols

There should not be a space between the type identifier and the name of the protocol encased in angle brackets.
Blocks

Blocks are preferred to the target-selector pattern when creating callbacks, as it makes code easier to read. Code inside blocks should be indented four spaces.

iOS Readability Parser

Hearie - News Aloud

Hearie - News Aloud

 

 

I have just released part of my source code in the Hearie project to be open source, this project will do the html readability parsing by objective-C. It still has some issues over threading, performance and may not work with all sites.

Feel free to use it and contact me if you have any issues

 

Hearie gets rid of distractions in webpages. Also, a high quality voice reads the content for you.

How many times have you complained your iPhone screen is too small to read? Hearie removes all useless contents including advertisments, links and more. Open your Safari, go to New York Times, tap our button and enjoy.

Hearie reads the content for you with human voice. Free your hands and eyes. Plug in your earphones and hear the content.

Installing App with iPhone Configuration Utility

iPhone Configuration Utility

iPhone Configuration Utility

 

I always have problems finding a good tutorial for my customers whenever I send them the adhoc app for testing, so I write this post to have a basic place for me and everybody else to send to their beta tester/customer without touching to iTunes with the crazy syncing process. This can be good for JailBreak iPhone as well but this is another story.

 

1/ Download iPhone Configuration Utility.

You can download the iPhone Configuration Utility for Windows here, and for Mac here.

2/ Plugin and find your device

You can find your device easily, and then choose add button as shown in the red box

iPhone Configuration Utility - Device

Show Devices in iPhone Configuration Utility

3/ Select your app

Open Your File Browser and select the file you need, in this case is JobFinder.app

iPhone Configuration Utility - SelectFile

Select Application File

4/ Go back to device and open the Applications Tab

iPhone Configuration Utility - Applications

Applications Tab

5/ Installing the app in

iPhone Configuration Utility - Install Applications

Install Applications

 

New Twitter XAuth and Sharing on iPhone

This Twitter sharing library for iPhone has a great User Interface, comparing to my current library for Twitter Sharing, the only problem is that it does not work with new XAuth project. So, I decided to take that UI and merge into my existing codebase for twitter xauth and sharing. The new library allow you to login, share and logout

https://github.com/vodkhang/Twitter-XAuth-and-Sharing

And here is the result. It looks great and really like the UIAlertView in iPhone

Login To Twitter with iPhone

Login To Twitter

Share on Twitter

Share on Twitter

 

 

 

 

 

 

 

 

 

 

 

 

http://amanpages.com/sample-iphone-example-project/multiple-login-for-twitteragent/

My book: Community and Opportunities


My iPhone Book

My iPhone Book

I am happy to announce that I encountered a book contract with Apress to write about iphone development. This will be a great opportunity and new experience for me when I have never written a real book before.

That is just part of the main content of this blog, I want to share my own thought over community support (as I already said at this blog post about Community Support) and how it would help me to reach this kind of opportunities. An Apress staff contacted me after he read my blog series about iphone development. This helps me to restate again that if you do good thing for other people, chance will come back. Real chance, real value, not an artificial reputation.

Supporting community and make lives better is my personal long-term goal as well as my company’s long-term goal.

 

Advertising:

Visit vworker to hire best employees

Applyzer – more statistics for iPhone Apps

Review example Review example

 

Just a quick note and introduction over Applyzer : a website that gather all reviews from all countries and rankings of your app in those countries. This is a good thing because iTune does not allow you to view all reviews at the same time and switching the country is so painful that nobody will ever do it. The ranking is also good that let you decide to focus on some countries rather than others if your app requires a little bit localization

 

Windows Phone 7 v.s iPhone Presentation in Barcampsaigon

Windows Phone 7 and iPhone Presentation

Windows Phone 7 and iPhone Presentation

Here is my presentation with Nghia Dang on the topic comparing the differences between Windows Phone 7 and iPhone Development. I share it here for others who cannot come. Contact me (vodkhang@gmail.com) or Nghia (nghiadang@kms-technology.com) if you have any questions:

Kms-Technology

iPhone Code Generation – Property

This is my new generation script, mainly copied from here with some improvements to meet my needs:

XCode Code Generation

XCode Code Generation

– Change the dealloc to [self.variable release] instead of [self.variable dealloc];

– Change the @outlet variable to check for the “UI” prefix rather than letting it put IBOutlet everywhere or I have to use 2 scripts at the same time.
– Add some of my own into the assign list

The second one is not a perfect solution for IBOutlet but considering that it doesn’t harm much except let some annoying IBOutlet out.

Twitter: XAuth + Sharing

DDSocialDialog for Twitter

DDSocialDialog for Twitter

Showing a place for logging and sharing a tweet in Twitter with my new library. You now can use XAuth without even understanding about how it works and you also have a nice facebook-style pop up.

For details about XAuth and how to use the XAuth functions, you can follow this link: Aralbalkan’s blog and his feather apps.

For showing a Twitter Pop up Dialog, I appreciate the effort of DDSocialDialog and the quick image is like in the left hand image.

I hope that this will help other iphone developers and me to cut their time and efforts to redo this dialog again and again.

 

iPhone Http Server – Bug Fix

Recently, I encountered a serious bug in Cocoa Http Server (for iPhone) that took me and my colleagues time to fix it. However, it turned out to be a simple, easy to fix bug.

If you use the sample code (e.g iPhoneHttpServer3.zip) in the google site, you will sooner or later, recognize a bug that if you upload a file B if file A is still uploaded, you get a crash. Another crash case is that you request to a page, turn off the server and turn it on again, and then upload a file into the server, you get a crash.

What’s going on? Why does this server not behave like any other web servers we know? Generally, the bug is due to the fact that some variables are not init in the correct place. The server assumes that whenever you send it a get request, it will init the data for handling the POST request, which is not always correct. Here is the way you can fix it. Or you can just redownload the whole sample code for CocoaHttpServer for iPhone here
In file HTTPConnection.h

@interface HTTPConnection : NSObject

{

// vodkhang

// Added properties

NSInteger dataStartIndex;

NSMutableArray *multipartData;

BOOL postHeaderOK;

}

// vodkhang

// Added methods

- (BOOL)supportsPOST:(NSString *)path withSize:(UInt64)contentLength;

@end

In file HTTPConnection.m

@implementation HTTPConnection : NSObject

/**

* This method is called after the socket has successfully read data from the stream.

* Remember that this method will only be called after the socket reaches a CRLF, or after it's read the proper length.

**/

-        (void)onSocket:(AsyncSocket *)sock didReadData:(NSData*)data withTag:(long)tag {

. . .

// Find some places look like this

if(expectsUpload)

{

// Reset the total amount of data received for the upload

requestContentLengthReceived = 0;

// Prepare for the upload

[self prepareForBodyWithSize:requestContentLength];

// Start reading the request body

uint bytesToRead = requestContentLength <

POST_CHUNKSIZE ? requestContentLength : POST_CHUNKSIZE;

[asyncSocket readDataToLength:bytesToRead

withTimeout:READ_TIMEOUT tag:HTTP_REQUEST_BODY];

// vodkhang

 // Add this line in

[self supportsPOST:@""  withSize:0];

}

else

{

// Now we need to reply to the request

[self replyToHTTPRequest];

}

}

// vodkhang

// Add this method:

/**

* Returns whether or not the server will accept POSTs.

* That is, whether the server will accept uploaded data for the given URI.

**/

- (BOOL)supportsPOST:(NSString *)path withSize:(UInt64)contentLength

{

//     NSLog(@"POST:%@", path);

dataStartIndex = 0;

multipartData = [[NSMutableArray alloc] init];

postHeaderOK = FALSE;

return YES;

}

@end

In file MyHTTPConnection.h

//  Remove properties dataStartIndex, multipartData and postHeaderOK
// Remove method `supportsPOST:(NSString *)path withSize:(UInt64)contentLength;`

In file MyHTTPConnection.m

// Remove method

- (BOOL)supportsPOST:(NSString *)path withSize:(UInt64)contentLength;

I hope it works well. If you have any problem, feel free to contact me at : vodkhang@gmail.com