您好,您能给我一个使用此方法的示例
+(NSString *)description
Run Code Online (Sandbox Code Playgroud)
我是否将描述与NSObject(任何类型的对象)或NSString的实例一起使用?
或者我是否在没有实例的情况下使用,直接使用NSObject(任何类型的对象)或NSString?
-(id)initWithStrAndDate: (NSString *)inString date:(NSDate *)inDate
{
if (self = [super init])
{
[self setStr:inString];
[self setDate:inDate];
}
return self;
}
-(id)initWithStr: (NSString *)inString
{
return [self initWithStrAndDate:inString date:[NSDate date]];
}
-(id)init
{
return [self initWithStr:nil];
}
Run Code Online (Sandbox Code Playgroud)
嘿伙计们,我不确定我是否知道如何使用"指定的初始化程序".首先不是
return [self initWithStrAndDate:inString date:[NSDate date]];
Run Code Online (Sandbox Code Playgroud)
这个错了?不应该这样:
return [self initWithStrAndDate:inString date:nil];
Run Code Online (Sandbox Code Playgroud)
还有为什么我们使用3种不同的初始化器?我的意思是什么时候我们使用" - (id)init"或" - (id)initWithStr:(NSString*)inString"或第一个?
DataController.h
@class Play;
@interface DataController : NSObject
- (unsigned)countOfList;
- (Play *)objectInListAtIndex:(unsigned)theIndex;
@end
Run Code Online (Sandbox Code Playgroud)
DataController.m
#import "DataController.h"
#import "Play.h"
@interface DataController ()
@property (nonatomic, copy, readwrite) NSMutableArray *list;
- (void)createDemoData;
@end
@implementation DataController
@synthesize list;
- (id)init {
if (self = [super init]) {
[self createDemoData];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
为什么你认为@interface定义了两次?还有()的含义是什么?不应该有一个类名,也许是括号之间的超类吗?
thedeck1.txt
1 4 7 10 13 16 19 22 25
5 3 6 9 12 15 18 21 24
27 2 28 8 11 14 17 20 23 26
Run Code Online (Sandbox Code Playgroud)
thedeck2.txt
1 7
4
10 13 16
19 22 25 28 3
6
9
12 15 18 21 24 27 2 5 8 11 14 17 20 23 26
Run Code Online (Sandbox Code Playgroud)
function.py
def readingdeck(file):
file = open(deck1.txt(or also deck2.txt), 'r')
total_deck = []
string_counter = 0
for line in file:
newline = line.rstrip('\n') …Run Code Online (Sandbox Code Playgroud)