[iPhone SDK] Why can't I message UI elements or other classes?

Hi there,
I confess to being a bit of a new hand at Cocoa -- I've been working through Aaron Hillegass's excellent book on the subject. Still, I haven't had any trouble like what I'm about to describe.
Everything was going swimmingly until I switched from noodling in desktop development over to Cocoa Touch. Here is an example application project using Apple's view-based app template to illustrate:
http://danilocampos.com/development/WTFXcode.zip (1.3 MB)
An IBOutlet, UILabel *label, is declared in the app delegate header. In the app delegate's implementation, several lines are dedicated to logging statements showing that applicationDidFinishLaunching was called and detailing my attempt to send messages to label. Sending setText to label fails, as does sending text to query its data. An NSAssert is called to compare the label's contents to the value it was sent. Assertion fails and app closes. Obviously, even if I comment out my assertion the app still isn't doing what it should. Everything compiles fine and the compiler doesn't log any warnings.
The ViewController nib has a UICustomObject for the app delegate. From there, the app delegate is wired to the UILabel.
Where am I going wrong here? Did Garbage Collection on the desktop environment spoil me and I'm forgetting to allocate something?
Also: It's not included in the example I uploaded, but I'm having the same trouble with sending messages to other NSObject sub-classes I make, even if I properly instantiate them and set them up as properties like in Apple's app templates. If anyone has a thought about that issue, I'd love to hear it too.
Thanks!
Message was edited by: Danilo Campos

I could be wrong on this, but I don't think you should have a reference to the AppDelegate in your NIB file. Get rid of that, and the IBOutlet definition in your AppDelegate.h.
In your viewController is where you should define the IBOutlet, and then wire it to the File's Owner instead of the AppDelegate.
You can still have a label stored in the app delegate, but you'd have to instantiate it using code, and then call an accessor in your view controller to get the pointer.
AppDelegate
-- .h --
@interface WTFXcodeAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
WTFXcodeViewController *viewController;
UILabel *label;
-- .m --
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after app launch
[window addSubview:viewController.view];
[window makeKeyAndVisible];
label = [[UILabel alloc] init];
NSLog(@"applicationDidFinishLaunching: %@", application);
NSString *theString = @"Update, **** you!";
NSLog(@"The string: %@",theString);
[label setText:theString];
NSString *labelText = [label text];
NSLog(@"Trying to message the label and ask for its text value: %@", labelText);
NSAssert(labelText == theString, @"The label text should match theString");
- (void)dealloc {
[label release];
// Rest of the releases
WTFViewController
-- .h --
@interface WTFXcodeViewController : UIViewController {
IBOutlet UILabel *label;
@property (nonatomic, retain) UILabel *label;
-- .m --
@synthesize label;
- (void)viewDidLoad {
label = //Some method in the app delegate to return your label
[super viewDidLoad];
- (void)dealloc {
[label release];
[super dealloc];

Similar Messages

  • Why can't I message picture from my iPhone to a noniphone

    why can't I message picture from my iPhone 4s to another non-
    iphone ?

    Settings>Messages>Send MMS>ON
    Settings>Cellular/Mobile>Cellular data ON
    If that doesn't work read the article below:
    iOS: Troubleshooting Messages

  • HT4623 I have an IPhone 5, I can receive instant messages but when I reply to the messages specifically to my friends samsung galaxy running droid he will not receive my message. Why not?

    I have an IPhone 5, I can receive instant messages but when I reply to the messages specifically to my friends samsung galaxy running droid he will not receive my message. Anybody having a simuler issue?

    Do you have a texting plan?

  • Why can I receive messages but can't send any

    I have a iPhone 3GS I can receive SMS messages but cannot send any please help also why does my screen look like this at the top and why do my keys stick

    Basic troubleshooting from the User's Guide is reset, restart, restore (first from backup then as new).  Try all of those, then if there are still issues, provide specifics of what is occurring.

  • I choose to restore from a safety backup in iTunes. It works ok, but iTunes is still asking to restore the iPhone. Why can't I get to syncronise the phone? I can't get the menue I am used to in iTunes. It only states "Klargjør iPhone" (Norwegian). Somethi

    I choose to restore from a safety backup in iTunes. It works ok, but iTunes is still asking to restore the iPhone. Why can't I get to syncronise the phone?
    I can't get the menue I am used to in iTunes. It only states "Klargjør iPhone" (Norwegian). Something like "Start up your iPhone". I've done this several times, restarted the iPhone and my computer, but I can't get ready to sync... The phone is working ok and my backup data is restored into the phone.

    Hi there,
    I would recommend taking a look at the troubleshooting steps found in the article below.
    iOS: Troubleshooting backup issues in iTunes
    http://support.apple.com/kb/ts2529
    -Griff W.

  • Why can't I message on my Mac. I open up my messages and it stays up there for a second or two. Then it will close out by itself. Help!

    Why can't I message on my Mac. I open up my messages and it stays up there for a second or two. Then it will close out by itself. Help!

    For some reason, the error box photo didn't appear in my post. Here it is:

  • HT3406 I want to deactivate my iPhone so I can receive text messages on my non-apple phone and use my iPhone as an iPod only. How do I do that?

    I want to deactivate my iPhone so I can receive text messages on my non-apple phone and use my iPhone as an iPod only. How do I do that?

    1800aplcare
    they can revoke ur imessage certificate for ur apple id and thus free up ur phone # out of the system

  • Why can't i receive photo texts from other IPHONE users

    Why can't I receive photo texts from other iphone users

    contact your carrier, your account may be having issues with MMS

  • Why can't I use my internet, when other Apple products Can?

    why can't I use my internet, when other Apple products Can?

    Hi helen xia,
    Which OS are you using? Please let us know the exact error message.
    Regards,
    Romit Sinha

  • Why can't my computer update elements 9 - keeps coming up as error and try later.  I can't now process RAW files it comes up as CR2

    why can't do updates for elements 9 keep coming up as "error in system try later"  I can't now process RAW files they come up as CR2.  This has happened in lightroom 5 also

    594594
    What is your program - Photoshop Elements 9 or Premiere Elements 9? If Photoshop Elements 9, you have posted in the wrong forum. You have posted in Adobe Premiere Elements Forum (video editing). Although Camera Raw allows for the import of raw format image and dng into a Premiere Elements project as source media, you cannot "process" it in the Camera Raw dialog. You need Photoshop Elements for that.
    If your program is Photoshop Elements, please re-post your thread in the Adobe Photoshop Elements Forum or wait for a moderator here to see your thread here and move it from here to there.
    Photoshop Elements
    Some information that might help as you take care of the above....
    Does your current problem exist with and without antivirus and firewall(s) disabled?
    Are you getting an error message (number/code) associate with your Help Menu/Update?
    The latest version of Camera Raw that is supported by version 9.0/9.0.1 seems to be 6.5. Do you have that currently installed?
    If you cannot get the program's Help Menu/Update to work for you, then download and install Camera Raw 6.5 from the following from Adobe
    For Mac
    http://www.adobe.com/support/downloads/detail.jsp?ftpID=5263
    For Windows
    Adobe - Adobe Camera Raw and DNG Converter : For Windows : Camera Raw 6.5 update
    What camera are you using to generate your raw format images.
    Camera Raw plug-in | Supported cameras
    If it is not yet supported by 6.5, then
    a. move to a later version of Photoshop Elements that supports a later version of Camera Raw that supports your camera.
    b. use the dng converter
    ATR

  • Why can't people hear me on the other end on my phone

    why can't people hear me on the other end on my phone

    your mic might not be working... exit the phone app and double click on the home button. this will bring up the multitasking apps. press and hold the apps and delete all of them with the red delete sign (does not remove the apps from the system). then shut down your iphone and turn it back on in a few seconds. after this, make sure mute is off (it will light up blue if its on) and try calling someone. this should solve the problem

  • Why can't I validate Premiere Elements 12

    Why can't I validate Premiere Elements 12  & Photoshop Elements 12 after successful serial number registrations?  Both are legitimate programs. I reinstalled as trial versions so that I could key in my serial numbers with no luck ! I have 3 days left before programs stop working!  I also chatted with an adobe rep with no help / resolution at all. He wanted to refer me to a technician who could help with my event viewer & have me pay for it! ... what a wise guy!! So far I received no help regarding my adobe programs! Please help!

    Pinkcat
    On what computer operating system are you trying to install Photoshop Elements 12 and Premiere Elements 12? For now I will assume Windows 7, 8, or 8.1 64 bit.
    Did you purchase these programs from Adobe direct as online downloads? Are you trying to install them one at a time with antivirus and
    firewall(s) disabled?
    1. Go to Control Panel/Programs and confirm that these programs are not listed under installed program.
    2. Make sure
    a. anti-virus and firewall(s) are disabled
    b. do a ccleaner run through (regular cleaner and registry cleaner parts)
    CCleaner - Download
    c. install Premiere Elements 12...if any problems, please look at
    http://www.atr935.blogspot.com/2014/04/pe12-premiere-elements-12-editor-will.html
    ATR Premiere Elements Troubleshooting: PE12: Sign In Failure (Connect to Internet or Fix Computer Clock)
    Assure that you are running the program from a User Account with Administrative Privileges and with Run As Administrator applied (see right click of desktop icon)
    Be sure to have QuickTime (latest version) installed on the computer with Premiere Elements 12.
    Also, we might delete the Adobe Premiere Elements Prefs file or the whole 12.0 Folder in which it exists....but that is on hold for now.
    Also, we might create a new User Account with Administrative Privileges and install and run program there....but that is on hold for now.
    If you want to do your own looking at the Event Viewer - right click Computer listing, select Manage, Event Viewer, Windows Logs and Application under Windows Logs. Look for an error or warning that appears related to the time and date of your failure event.
    Please review and consider.
    We will be watching for your follow up.
    Thank you.
    ATR
    Add On...Once Premiere Elements install is successful, then we will move on to Photoshop Elements.

  • Does Element 11 support Sony A7r? why can't I use my element 11 to process images produced by Sony A7r?

    does Element 11 support Sony A7r? why can't I use my element 11 to process images produced by Sony A7r?

    If you convert your files to the Adobe Raw format (DNG)thyry will open in PSE11.
    Windows download (.exe file) click here DNG Converter 8.3
    Mac download (.dmg file) click here DNG Converter 8.3
    You can convert a whole folder of raw images in one click. See this quick video tutorial:
    You Tube click here for DNG Converter tutorial

  • I am unable to send text messages in Message. I can receive messages but not send. I am able to do both with my iPhone. Why can't I send?

    Why can't I send text messages on my iPad? I can send and receive messages on my iPhone.

    Hi Kathy,
    Happy Holidays!  Do you have an iPad with cellular service and a text-messaging plan?
    Send messages with your iPhone, iPad, or iPod touch - Apple Support
    http://support.apple.com/en-us/HT201287
    What's the difference between SMS/MMS and iMessage?
    SMS/MMS lets you send text messages and photos to other cellular phones or devices. iMessage lets you send text messages and photos to another iOS device over Wi-Fi, without worrying about text-messaging charges (cellular data charges may apply). 
    What do I need to use SMS/MMS and iMessage?
    Here's what you need to use SMS/MMS and iMessage:
    SMS/MMS: A text-messaging plan. Contact your carrier for more information.
    iMessage: An iPhone, iPad, or iPod touch with iOS 5 or later.
    How do I know if my message used SMS/MMS or iMessage?
    You can tell which type of message you're sending by the color of the Send button and text bubble.
    SMS/MMS: Send button and text bubbles are green.
    iMessage: Send button and text bubbles are blue.
    How can I link my iPhone number with Messages on my iPad, iPod touch, or Messages for Mac?
    When you sign in to Messages with your Apple ID on your iPhone, you link your phone number to your Apple ID. If you then sign in to Messages with the same Apple ID on your iPad, iPod touch, or Mac, Messages will link that device to your phone number as well.
    I hope this information helps ....
    - Judy

  • Why am I seeing my daughter's contacts only on my MB (synced I assume from her iPhone) and why does my text messaging on the MB all viewed like she is receiving them?  Even on my phone, a message I sent to myself as a test shows up as "mom"

    Why are my daughter's contacts the only one showing up on my MB and why do all text messages now, including on the MB and my iPhone show up now as if she's receiving them, even when they are sent to me based on her contact list?

    It's called iMessage, new in iOS 5.0...these messages are going as iMessages, and as designed, they appear on all of your iOS devices(your Apple ID on your daughter's phone). Either turn iMessage off on your daughter's phone or get her her own Apple ID & wipe her phone & then setup it up again using her own Apple ID. Your daughter having her own Apple ID is recommended if you want to fully take advantage of iCloud, FaceTime, iMessage, etc. She can still use your iTunes account.

Maybe you are looking for

  • How do I write a letter to print on my MacBooK?\

    tUsing my MacBook Air,where do I go to write a letter to print and mail? What do I click on to get started? Thanks from a 71 year old (young).

  • Why can I no longer find my podcast under the keywords in my feed?

    We're having problems with our podcast showing up on itunes. A few weeks ago, our podcast just stopped appearing under the proper keyword searches. Our podcast is called Sequence Break XIV and out itunes url is: http://itunes.apple.com/us/podcast/seq

  • Widgets in templates

    The problem I am having is creating an editable region for widgets I've inserted into my template. I've inserted collapsible panels into what will be the sidebar to the template of my website. I have figured out how to create an editable region in th

  • Where is my text box in final cut pro? I cannot change the default text at all?

    Hi, as the title says, I use a default final cut pro title or ending for a video and I cannot change the text, all youtube tutorials just show that you click on the text box, the boxes appear, and then to the right in the text window you literally ju

  • Standard Workflow for PR Release Multi-level

    Good day, I have a multi-level PR release strategy connected to workflow and using exit M06B0001 Structure is as follows Release Codes: A1 - first level A2 - first level (back-up) B1 - second level B2 - second level (back-up) Objective: (upon creatio