'object' undeclared <first use in this function>

Posted by Mohit Deshpande on Stack Overflow See other posts from Stack Overflow or by Mohit Deshpande
Published on 2010-05-24T23:32:54Z Indexed on 2010/05/24 23:41 UTC
Read the original article Hit count: 417

Filed under:
|
|
|

I am using Winchain to develop on my Windows 7 machine. Here is my code:
iPhoneTest.h

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>


@interface iPhoneTest : UIApplication {
    UITextView *textview;
    UIView *mainView;
}

@end

iPhoneTest.m

#import "iPhoneTest.h"
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <CoreFoundation/CoreFoundation.h>


@implementation iPhoneTest
-(void)applicationDidFinishLaunching:(id)unused {
    UIWindow *window;
    struct CGRect rect = [UIHardware fullScreenApplicationContentRect];
    rect.origin.x = rect.origin.y = 0.0f;

    window = [[UIWindow alloc] initWithContentRect: rect];
    mainView = [[UIView alloc] initWithFrame: rect];
    textView = [[UITextView alloc] init];
    [textView setEditable:YES];
    [textView setTextSize:14];

    [window orderFront: self];
    [window makeKey: self];
    [window _setHidden: NO];
    [window setContentView: mainView];
    [mainView addSubview:textView];

    [textView setText:@"Hello World"];

}
@end

main.m

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "iPhoneTest.h"


int main(int argc, char *argv[]) {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    int ret = UIApplicationMain(argc, argv, [iPhoneTest class]);
    [pool release];
    return ret;
}

Makefile

INFOPLIST_FILE=Info.plist
SOURCES=\
    main.m \
    iPhoneTest.m

CC=/usr/local/bin/arm-apple-darwin-gcc
CFLAGS=-g -O2 -Wall
LD=$(CC)
LDFLAGS=-lobjc -framework CoreFoundation -framework Foundation -framework UIKit     -framework LayerKit
PRODUCT_NAME=iPhoneTest
SRCROOT=/iphone-apps/iPhoneTest

WRAPPER_NAME=$(PRODUCT_NAME).app
EXECUTABLE_NAME=$(PRODUCT_NAME)
SOURCES_ABS=$(addprefix $(SRCROOT)/,$(SOURCES))
INFOPLIST_ABS=$(addprefix $(SRCROOT)/,$(INFOPLIST_FILE))
OBJECTS=\
    $(patsubst %.c,%.o,$(filter %.c,$(SOURCES))) \
    $(patsubst %.cc,%.o,$(filter %.cc,$(SOURCES))) \
    $(patsubst %.cpp,%.o,$(filter %.cpp,$(SOURCES))) \
    $(patsubst %.m,%.o,$(filter %.m,$(SOURCES))) \
    $(patsubst %.mm,%.o,$(filter %.mm,$(SOURCES)))
OBJECTS_ABS=$(addprefix $(CONFIGURATION_TEMP_DIR)/,$(OBJECTS))
APP_ABS=$(BUILT_PRODUCTS_DIR)/$(WRAPPER_NAME)
PRODUCT_ABS=$(APP_ABS)/$(EXECUTABLE_NAME)

all: $(PRODUCT_ABS)

$(PRODUCT_ABS): $(APP_ABS) $(OBJECTS_ABS)
    $(LD) $(LDFLAGS) -o $(PRODUCT_ABS) $(OBJECTS_ABS)

 $(APP_ABS): $(INFOPLIST_ABS)
    mkdir -p $(APP_ABS)
    cp $(INFOPLIST_ABS) $(APP_ABS)/

 $(CONFIGURATION_TEMP_DIR)/%.o: $(SRCROOT)/%.m
    mkdir -p $(dir $@)
    $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@

 clean:
    echo rm -f $(OBJECTS_ABS)
    echo rm -rf $(APP_ABS)

When I try to compile it with make, I get

iPhoneTest.m: In fucntion '-[iPhoneTest applicationDidFinishLaunching:]'
iPhoneTest.m:15: error: 'testView' undeclared <first use in this function>
iPhoneTest.m:15: error: <Each undeclared identifier is reported only once for each function it appears in>

Can anyone spot the problem?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c