Hello,
I am totally new and are trying to learn how to create iPhone apps.
When learning how to update the screen, I am trying to move a NSString around, but it multiplies and is positioned in different places. Can anyone tell me what I am not understanding? I am also an old Java guy, perhaps I am not understanding the language correctly...
Please see code below.
Thanks in advance!
Cheers,
Niklas
I am totally new and are trying to learn how to create iPhone apps.
When learning how to update the screen, I am trying to move a NSString around, but it multiplies and is positioned in different places. Can anyone tell me what I am not understanding? I am also an old Java guy, perhaps I am not understanding the language correctly...
Please see code below.
Thanks in advance!
Cheers,
Niklas
Code:
//
// MyView.m
// HelloWorld
//
// Created by nic on 2009-10-13.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "MyView.h"
#import "TextClass.h"
@implementation MyView
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
// Initialization code
location = CGPointMake(40, 20);
id textObject = [[TextClass alloc] init];
font = [UIFont systemFontOfSize:24];
hello = [textObject getText];
hello = [textObject getText];
}
return self;
}
- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
location = point;
[self setNeedsDisplay];
return self;
}
- (void)drawRect:(CGRect)rect {
CGPoint location2 = CGPointMake(10, 40);
[[UIColor whiteColor] set];
[hello drawAtPoint:location withFont:font];
NSString *l = [NSString stringWithFormat:@"%d", [hello length]];
[l drawAtPoint:location2 withFont:font];
}
- (void)dealloc {
[super dealloc];
}
@end
Code:
//
// MyView.h
// HelloWorld
//
// Created by nic on 2009-10-13.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
CGPoint location;
NSString *hello;
UIFont *font;
@interface MyView : UIView {
}
@end