(lldb) in output. What does it mean

Joined
Mar 14, 2012
Messages
12
Reaction score
0
Points
1
I am just learning Ojective C and had an example program working fine. I started adding more classes and to it and when I run it builds ok but in All output it says just (lldb) and not the results I was looking for. Any ideas?

Thanks
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
You have to be more specific, and tell us where you are trying to output the resullts.

If your trying to output the results to the Xcode terminal, then you use the NSLog(@"") command.

Post your output code lines, but not the whole program, unless its small.

Regards Mark
 
OP
M
Joined
Mar 14, 2012
Messages
12
Reaction score
0
Points
1
//
// Simple Car.m
// Car APP
//
// Created by Robert Glasco on 12-05-10.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "Simple Car.h"

@implementation Simple_Car

// set methods

- (void) setVin: (NSNumber*)newVin {

[Vin release];
Vin = [ [NSNumber alloc] init];
Vin = newVin;
}
- (void) setMake: (NSString*)newMake {
[Make release];
Make = [ [NSString alloc] initWithString:newMake];

}
- (void) setModel: (NSString*)newModel {
[Model release];
Model = [ [NSString alloc] initWithString:newModel];

}

- (void) setCounrty: (NSString*)newCountry {
[Country release];
Country = [ [NSString alloc] initWithString:newCountry];
}

- (void) setColour: (NSString*)newColour {
[Country release];
Colour = [ [NSString alloc] initWithString:newColour];
}

- (void) setPrice: (NSNumber*)newPrice {
[Price release];
Price = [ [NSNumber alloc] init];
Price = newPrice;
}



- (void) dealloc
{
[Vin release];
[Make release];
[Model release];
[Country release];
[Price release];
[Colour release];
[super dealloc];
}


// Convenience method

- (void) setMake: (NSString*)newMake
andModel: (NSString*)newModel {

//Reuse our methods from earlier
[self setMake:newMake];
[self setModel:newModel];


}

// get methods

- (NSString*) make {
return Make;
}
- (NSString*) model {
return Model;
}
- (NSNumber*) vin {
return Vin;
}

- (NSString*) country {
return Country;
}

- (NSString*) colour {
return Colour;
}

- (NSNumber*) price {
return Price;
}



@end
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
The problem with your setter methods is that you are Alloc & init new class objects without needing too, your getter methods are ok, but your setter methods need to be more like the example below.

Code:
//Simple_Car.h

#import <Foundation/Foundation.h>

@interface Simple_Car : NSObject
{
	NSNumber *vin;
	NSString *make;
	NSString *model;
	NSString *country;
	NSString *colour;
	NSNumber *price;
{

@property (nonatomic, retain)NSNumber *vin;
@property (nonatomic, copy)NSString *make;
@property (nonatomic, copy)NSString *model;
@property (nonatomic, copy)NSString *country;
@property (nonatomic, copy)NSString *colour;
@property (nonatomic, retain)NSNumber *price;

@end


//Simple_Car.m

#import "Simple_Car.h"

@implementation Simple_Car

- (void)setVin:(NSNumber *)newVin
{
	[vin release];
	vin = [number numberWithInt:newVin];
}

- (NSNumber *)vin
{
	return vin;
}

- (void)setMake:(NSString *)newMake
{
	id newString = [newMake copy];
	[make release];
	make = newString;
}

- (NSString *)make
{
	return make;
}


// Convenience Method

- (void)setMake:(NSString *)newMake andModel:(NSString *)newModel
{
	[self setValue:newMake forKey:@"make"];
	[self setValue:newModel forKey:@"model"];
}

@end

I have only shown some of the setter and getter methods, but you'll get the point, when using the NSNumber class, you have to tell it what type of number to use, eg int or float ect.

The way you prevously wrote your convenience method was also OK, but I have shown you another way to do it with using KVC, Key Value Coding, which is a more modern way to do things.

But what I would say is that you should probably use the @Synthesize method to have the
setter and getter methods implemented for you, like this example below.

Code:
//Simple_Car.h

#import <Foundation/Foundation.h>

@interface Simple_Car : NSObject
{
	NSNumber *vin;
	NSString *make;
	NSString *model;
	NSString *country;
	NSString *colour;
	NSNumber *price;
{

@property (nonatomic, retain)NSNumber *vin;
@property (nonatomic, copy)NSString *make;
@property (nonatomic, copy)NSString *model;
@property (nonatomic, copy)NSString *country;
@property (nonatomic, copy)NSString *colour;
@property (nonatomic, retain)NSNumber *price;

@end


//Simple_Car.m

#import "Simple_Car.h"

@implementation Simple_Car

@synthesize vin, make, model, country, colour, price;

// Convenience Method

- (void)setMake:(NSString *)newMake andModel:(NSString *)newModel
{
	[self setValue:newMake forKey:@"make"];
	[self setValue:newModel forKey:@"model"];
}

@end

That one line that starts with @synthesize will automatically create the setter and getter methods for you, and you can then simply add the assign retain or copy attributes to the
properties, to adjust the setter method types.

Hope this helps.

Regards Mark
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
Sorry one mistake in the code I posted in the first example.

This line.

Code:
	vin = [number numberWithInt:newVin];

Should be.

Code:
	vin = [NSNumber numberWithInt:newVin];

Also the NSNumber class can be assigned various number type like this.

Code:
	vin = [NSNumber numberWithFloat:newVin];
	vin = [NSNumber numberWithDouble:newVin];
	vin = [NSNumber numberWithLong:newVin];
       //ect.

https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40003704

Regards Mark
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top