Home | About | All Things STL | Dev | Investing | Links | Site Search | shanzi @sina | uudaddy | Login | Register

Main Content RSS FeedRecent Articles

Objective-C code hall of shame »

Today I found out I made a dumb mistake while deleting an NSMutableArray.

for(int ii=0; ii<[myNSMutableArray count]; ii++)
{
myNSMutableArray removeObjectAtIndex:ii];
}

The reason being it will get confused about the elements (index) during the loop.

The correct way is to use removeAllObjects method.

Code signing error in Xcode »

Had my share of code signing problem (esp. the enterprise distribution certificate) in my Xcode development. Luckily, stackoverflow rescued me as always. It seems a lot problem is due to the Xcode upgrade, project name change, provision profile/distribute certificate expiring etc. And the solution is usually delete or comment out the offending line. Like below. To go to the project file, I usually do in the command line, “cd projectName.xcodeproj”, then “vi project.pbxproj”.

http://stackoverflow.com/questions/1760518/codesign-error-provisioning-profile-cannot-be-found-after-deleting-expired-prof

http://stackoverflow.com/questions/5758154/code-sign-error-provisioning-profile-cant-be-found

I encountered another problem related to the provisioning profile expiration, the distribute certificate appears twice in the Keychain, even after I deleted it explicitly. It turns out the old distribute certificate came back after I opened the project in Xcode (presumedly it came back when the old provision profile associated with the project got loaded). So the workaround is to delete the old distribute certificate again after opening the project in Xcode.

http://stackoverflow.com/questions/5932522/codesign-error-certificate-identity-appearing-twice

Btw, saw an interesting idea from Mobile Iron regarding the enterprise distribution certificate. Normally the certificate expires in a year. In last 30 days it will prompt the user something like “the provision profile will expire in a few days…”, not good user experience. There is no way to renew it before it expires either. So the workaround suggested by MI is create 2 certificates, and create the second 6 months before the expiration and have user update the app. This way, essentially the app got extended 6 months. And so on. There is one catch in Xcode 4.3.3 I am using. It only recognizes the provision profile that was created earlier (or expires earlier). The workaround there is delete the earlier provision profile :D

Consuming a PHP SOAP web service from C# client »

I need to create a SOAP client in C#, and in order to test it I need a SOAP web service. Since my hosting company uses MySQL/PHP technology stack, I am using this PHP Soap web service example.

For the C# soap client, I am following this example on stackoverflow. But there is one problem when I tried to run the example. I got the error (exception) like the following:
The content type text/xml; charset=ISO-8859-1 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly.

Again I found this thread on stackoverflow which seems relevant. It talked about the custom message encoder developed by Microsoft, and Paul Morgado’s addition to the CustomTextMessageEncoder class (just add his method at the end of the class). There is one more thing, the configuration file for the app. In my case, it’s something like the following: (note the messageVersion and bindingElementExtensions definition, there was some error in the Microsoft documentation regarding the latter one).

Read the rest

Set up SVN (Subversion) on local machine (Windows) »

I need to do some development work on Windows, using Visual Studio. I like to have a simple source code control system, in recent years I have used CVS, Subversion and git (on Mac). I did a google search on Subversion and found some instructions regarding setting up Subversion.

Setting up Subversion on Windows

and this one

Installing and Configuring SVNServe and TortoiseSVN on Windows

Download/install the SVN server and starting the windows service was relatively straightforward. So as the Tortoise SVN client. Couple things keep in mind:

1) Some sites requires registration or install additional software, I chose sites that does not require registration.

2) I found sometimes I can not open up svn://localhost successfully, in the same command prompt window where I start the SVN service. After I close the command prompt and tried again, it worked. The commands I used are:

set SVN_EDITOR=c:\windows\system32\notepad.exe
svn mkdir svn://localhost/myproject

2012 Year in Review »

I took this cue from Kurby Turner, the independent Mac/iOS developer, as I think it might be helpful to reflect a year’s work, life, effort, etc. As the old Chinese saying goes “Ji Wang Kai Lai” (learn from past, and look forward to the future).

New job: Software Development
Today is my one year anniversary at my new employer. Looking back, from the initial ramp up to more comfortable work on my own pace, and then deliver the first iOS (iPad) app to the field, back end work, report work and support. I feel good about my effort and the support I got from my coworkers. Sometimes my wife will ask me “why it took so long for you to complete a project”? Because it’s not trivial to do it.

I also wrote a few blog posts on iOS app development, and the back end (.Net) web service. I plan to do the same as times goes. Generally speaking, now I have more confidence doing customized app development, full life cycle, and from front to back end (all tiers).

Family
Our daughter goes to the Hope Montessori Infant Toddler Community at Creve Coeur (off Manson road, near Olive Blvd). We are truly blessed with the teachers and staffs at the Hope family (I consider them as family, both adults and children, because sometimes they are better than family :-) . Serenity (Yoyo) learned English and all kinds of things there, which laid a good foundation for her future. For us, we learned parenting lessons there. Sometimes I wonder how much quality time I spent there, from afternoon pickup, to field trip, to social (work-day, Fettuccine, Montessori and Vino, the FMV movie). We watched the FMV movie with great fun, my wife and my friends (couple) did not attend the FMV event, and really enjoyed the movie after I showed them.

Trips
We did one family vacation, and I had 2 business trips in year 2012. We went to Orange Beach, Alabama in the Memorial Day weekend, with Chinese friends. We drove there. It’s funny Yoyo would not go to bathroom on the road, she wants to use bathroom in the hotel or condo (destination). For the business trip, I visited 2 mines in West Virginia, the 2 hours I spent in underground mine is both interesting and a bit unsettling. That’s the first time I visited mines (both surface and underground). In November I visited Las Vegas, stayed in Palazzo (Venetian), which I stayed 3 years ago when I attended AU (Autodesk University, the developer/user conference) in 2009.

Personal Finance
As I wrote this post, I found I made both good moves and bad moves on this topic. I did well in 401k accounts (because I did nothing). But not in the Scottrade brokerage and IRA accounts (because I tried to do too much). Overall I still did ok, because majority of my assets are in 401k (both existing accounts and new account).

Today (01-03-2012) as I listened to Charlie Ellis on the Consuelo WealthTrack podcast, I can not agree more on one comment from Charlie: we all strive to be above average in school or at work. In investing being average is actually not too bad. I understand what meant: 80% of mutual funds perform below average (the index), hedge fund and individual investors are not doing better. So in other words, being average is actually in the top 20% :-)

Read the rest

Some tips when creating WCF web service for iPad consumption »

Continuation of previous post.

1) WCF get does not like “NULL” column in the query results

2) // note the “id” should match in declaration and method
Read the rest

Creating WCF web service II »

A continuation of previous post.

1) Visual Studio, publish web service: check destination IIS app
Before the change, the error was “cannot show the content of the folder”.

2) Add this line to the service.cs (service class C# file), to work around/avoid a problem, asp .net compatibility issue. Do something like this:

[ServiceBehavior]
[AspNetCompatibilityRequirements(RequirementsMode=
AspNetCompatibilityRequirementsMode.Allowed)]
class BarService : IHelloContract
{
// …
}

Refer to wenlong

3) Bad request: it appears to be a class rename problem, Visual Studio has a “red” warning sign, follow it and accept “update”, rebuild.

Two mac tips »

1) This puzzelled me for a while, my macbook air run out of space often. I was trying to use the build “Finder” to find large files, delete files and some unused apps, to no avail. I did some more google and used this Mac App “FindSpace”. And I found this directory /var/vm has some large swap files. Aha. Found the culprit. This article from osxdaily has more explanation.

2) Old Macbook heat. My 3 years old macbook air recently has the problem of overheat. It heated up fairly quickly after using 10 to 15 minutes. Did some google and found this one described my symptom well. The solution appears to be “SMC reset”. I did it yesterday and it works better at least for now…

Three way to create customized input control for UITextField »

Recently I need to create some customized textfield to input numbers and text on iPad. I don’t like the default keyboard on iPad because it takes too much of the screen, and in some cases covers up the input field.

1) From iphonedevsdk: What is proper way to do UITextField text change call back? (this also mentioned by stackoverflow)

[textField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventTouchDown];

The downside of this approach is: it takes a press (a tap and hold) to trigger the event.

2) InputView
Create a customized view such as this one at raywenderlich, then set the inputView of textfield. I used this approach to create a number pad that used to only input numbers. There is some limit to this approach as well: the location of customized input view is usually fixed, and in my case (a double picker) for text field (table cell), that is not ideal. I was using pop over controller (again raywenderlich), combined with approach 1, the user does not like the “hold”. After I changed to approach 2, the user does not like the fixed location of input view. So I did more research, and eventually I found the following approach that works for me.

One tip: make sure lock the input view, otherwise it will mess up things after iPad rotation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return NO;
}

3) self delegate, UITextFieldDelegate

Make sure do this in viewDidLoad (or other place initialize the text field):
myTextField.delegate = self;

This way I could have both “single tap” and the pop over controller.

Create .NET WCF Restful web service for iOS »

I need to create a .NET web service consumable by iOS device. Did some research and found out WCF Restful service is the way to go. I used the following examples (tutorials) to construct my web service.

0) Basic Resource Service (link here).
This is basically a self hosting web service run in a main program. A good starting point to learn dataContract, webHttp, etc.

1) I need to change from a console app to a web service, and host on IIS, for this refer to
project 1
and
2(Space Service, a WCF web service app)

2) I need to combine 2 services into one program, and I referred to endPoint.tv plural sight podcast “Building RESTfil services with WCF”

The video above mentioned the httputil.js, HTTP POST/PUT utility, which is handy to test “POST” method. Another tool I used to test GET/POST, is “fiddler”.

A Guide to Designing and Building RESTful Web Services with WCF 3.5, also by Aaron Skonnard, Pluralsight

Essentially here we need to design a scheme (end points) for hosting multiple services.

3) Database connection, I used sql client, which is pretty vanilla.

4) Use pretty path instead of port number (routing service, refer to SimpleREST service again)

Also “code project” example

http://www.codeproject.com/Articles/105273/Create-RESTful-WCF-Service-API-Step-By-Step-Guide

// 最新推荐 Noteworthy
  • *new* 01-05-13: Most recent credit card offers
  • uudaddy (7-09-11): Airline and hotel credit card offers
  • my iPhone apps (4-14-11): myNestEgg ~ retirement income calculator; collegeFund ~ college savings calculator
  • houseOfKittyBlog 06/06/2008: The Inspiration Behind Hello Kitty – Shintaro Tsuji, Founder and CEO of Sanrio
  • Buffett on Market 12/10/2001: Whats in the future for investors
  • Google Ad

    (**use your own discretion for the the following links**)
  • Author作者

    "古人云,人不自信谁人信之." Others won't believe in you unless you believe yourself. --Chinese proverb

    Hello, world :-) I am not another expert. I am an ordinary guy who believes: by lifetime learning, hard and independent work and discipline, little guys can achieve their dreams, too.

    I grew up in China. Currently I am working on iOS (iPhone/iPad) app development. Here I'm also blogging about iOS app/software development, business, personal finance, and other fun stuffs in life. You can leave comment here or Email me: if you wish to remain private.

  • App dev

  • blog

  • China

  • finance

  • Links

  • Major

  • Saint Louis

  • Shanghai

  • Meta

  • Disclaimer声明

    See Disclaimer Page
  • Valid XHTML 1.0 Transitional