Feb 22, 2013

(XCode) How to search text in xib files

After several months of dev, a project could easily become ugly, probablly contains many used resources files(like pngs). It is easy to remove images that you know they are not using anymore, but that's not working for these looks unfamiliar. So i need to check their existence, it's simple to do a search in xcode, but xcode doesn't search in the xib files. Here is a line of command you can use in the terminal:

grep -i -r --include=*.xib "text you want to search" /your project's path

This command could search for all files (*.*).

Jun 27, 2012

(XCode) How to have lower simulator in Xcode 4.3 of Lion

The Xcode 4.3 does not have a simulator other than 5.1 and 4.3, but sometimes we need to test apps on the lower environment. So here is the trick: You need to have lower Xcode installation files, and copy the simulator folders to Xcode 4.3.

For exemple:
sudo mv /XCode file/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk/ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/

Jan 4, 2012

(Linux) Couldn't start Apache in Lampp

After upgrading Lampp to the latest version, apache could not be started, the error message is:

/opt/lampp/bin/php: error while loading shared libraries: /opt/lampp/lib/libsybdb.so.5: cannot restore segment prot after reloc: Permission denied
XAMPP: Starting Apache with SSL …
XAMPP: Error 1! Couldn't start Apache!
XAMPP: Starting diagnose…
XAMPP: Sorry, I've no idea what's going wrong.


It needs to disable selinux by using this command:

setenforce 0

Aug 23, 2011

(Android) How to listen MessageEvent in XMPP with asmack

The asmack could not load providers from smackx.jar automatically, if any project needs listen MessageEvent (composing, delivered, displayed, offline etc.), these lines must be added manually.

After established a connection:
connection.connect();
ProviderManager pm = ProviderManager.getInstance();

// Add extension provider
pm.addExtensionProvider("x", "jabber:x:event",new MessageEventProvider());

Dec 7, 2010

(iOS) Available font family

A good example to list all available font family of iOS system. Check it out.

Nov 19, 2010

(iPhone)How to display different color text

There are several ways to display different color text in iOS device.
  1. Use multiple UILabel and each contains different font style.
  2. Use HTML tag and UIWebView.
  3. Use NSMutableAttributedString, this classe is added in iOS from 3.2, it needs Core Text to render rich text on the view. AliSoftware created a useful classe UIAttributedLabel which is an UILabel's subclass and supports NSMutableAttributedString. Check AliSoftware's github for more information.

Aug 19, 2010

(iPhone)How to customize UIAlertView

First solution is using addSubview which add subviews into an UIAlertView, just don't forget add newlines in the initWithTitle method's message to make sure you have enough space for subviews. Like :

[[UIAlertView alloc] initWithTitle:@"Title" message:@"\n\n\n" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil]

But this solution couldn't change UIAlertView's background, here is second solution that creates an UIAlertView's subclass, overrides several methods (setAlertText, alertText, drawRect, layoutSubviews and show), Joris Kluivers made an excellent sample, check it here : CustomAlert