Category: Education
Updated: May 29, 2014
Version: 1.1.0
Size: 4.2 MB
Language: English
Link: itunes
NSLog ( @"The current date and time is: %@", [NSDate date] );You can log an object to the console. The NSLog function calls the description method on the object, and prints the NSString which is returned. You can override the description method in your class to return a custom string.
#import "Photo.h" @implementation Photo - (NSString*) caption { return caption; } - (NSString*) photographer { return photographer; } @end
#import <Cocoa/Cocoa.h>
@interface Photo : NSObject {
NSString* caption;
NSString* photographer;
}
@end
#import <Cocoa/Cocoa.h>
@interface Photo : NSObject {
NSString* caption;
NSString* photographer;
}- caption;
- photographer;@end
#import <Cocoa/Cocoa.h>
@interface Photo : NSObject {
NSString* caption;
NSString* photographer;
}- (NSString*) caption;
- (NSString*) photographer;@end
#import <Cocoa/Cocoa.h>
@interface Photo : NSObject {
NSString* caption;
NSString* photographer;
}- (NSString*) caption;
- (NSString*) photographer;- (void) setCaption: (NSString*)input;
- (void) setPhotographer: (NSString*)input;@end
// string1 will be released automatically
NSString* string1 = [NSString string]; // must release this when done
NSString* string2 = [[NSString alloc] init];
[string2 release];
NSString* myString = [NSString string];
NSString* myString = [[NSString alloc] init];
NSNumber* value = [[NSNumber alloc] initWithFloat:1.0];
[photo setCaption:@"Day at the Beach"];
output = [photo caption];
photo.caption = @"Day at the Beach";
output = photo.caption;
[object method];
[object methodWithInput:input];
output = [object methodWithOutput];
output = [object methodWithInputAndOutput:input];
id myObject = [NSString string];
NSString* myString = [NSString string];
function1 ( function2() );
[NSString stringWithFormat:[prefs format]];
-(BOOL)writeToFile:(NSString *)path atomically:(BOOL)useAuxiliaryFile;
BOOL result = [myData writeToFile:@"/tmp/log.txt" atomically:NO];
+ (UIColor*) randomColor
{
float red = arc4random() % 256;
float green = arc4random() % 256;
float blue = arc4random() % 256;
return [UIColor colorWithRed:red/255.0 green:green/255.0 blue:blue/255.0 alpha:1.0];
}