Cocoa-Matic

iPhone, iPod touch, iPad tutorials, examples and sample code. Come and get it!

Wednesday, January 26, 2011

XCode Linker error: Symbol(s) not found

Came across a weird error today:

Objc-class-ref-to-[ClassName] in MainController.o
Symbol(s) not found
Collect2: Id returned 1 exit status

For some reason the reference to the class in question is not listed under Compile Sources. Thankfully, it's an easy fix.

1. Under Groups & Files, expand Targets
2. Expand the compile target
3. Expand Compile Sources (xx)
4. Check to see if all of your .m files are listed. If not, drag the missing files in.
5. Recompile and run.

So, not sure why this happens, but luckily there's an easy fix.

Labels: ,

UITextField horizontal and vertical alignment

Horizontal alignment in a UITextField was quick and easy to find:
myTextField.textAlignment = UITextAlignmentLeft;
myTextField.textAlignment = UITextAlignmentCenter;
myTextField.textAlignment = UITextAlignmentRight;

Vertical alignment in a UITextField is equally as easy, just a little harder to find:
myTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
myTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentTop;
myTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentBottom;
myTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;

Enjoy!

Labels: , , ,

Wednesday, January 12, 2011

Replace UINavigationBar background with image

Sometimes you want to show off some creativity in your apps. One of the easiest ways to do that is by changing the look of the UINavigationBar. Modifying the color is one way and is a trivial task in Interface Builder. What about replacing it entirely with an image? Turns out that's not too difficult either. Here's how...

We're going to use Categories. What are Categories?
From CocoaDevCentral.com: Categories are one of the most useful features of Objective-C. Essentially, a category allows you to add methods to an existing class without subclassing it or needing to know any of the details of how it's implemented.

This is particularly useful because you can add methods to built-in objects. If you want to add a method to all instances of NSString in your application, you just add a category. There's no need to get everything to use a custom subclass.


Read more »

Labels: , , ,

Wednesday, September 1, 2010

NSDate number of days between two dates

Date objects in programming are typically both extremely common and notoriously tricky due to the many different syntaxes involved. These rules apply to iPhone development. In one application I created, I needed the number of days between 2 dates in several instances. As there is no simple NSDate2 - NSDate1 function built-in to return the number of days apart, I wrote a function to accomplish the task. Here it is...
Read more »

Labels: , , , , ,


« Older Entries  
Newer Entries »