小编Mic*_*l C的帖子

[NSObject描述]

您好,您能给我一个使用此方法的示例

+(NSString *)description
Run Code Online (Sandbox Code Playgroud)

我是否将描述与NSObject(任何类型的对象)或NSString的实例一起使用?

或者我是否在没有实例的情况下使用,直接使用NSObject(任何类型的对象)或NSString?

c objective-c foundation ios

5
推荐指数
1
解决办法
9591
查看次数

指定初始化程序

-(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"或第一个?

iphone xcode objective-c ios

3
推荐指数
1
解决办法
2764
查看次数

两个接口?

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定义了两次?还有()的含义是什么?不应该有一个类名,也许是括号之间的超类吗?

iphone objective-c ios

0
推荐指数
1
解决办法
184
查看次数

python从中获取列表

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)

python python-3.x

0
推荐指数
1
解决办法
118
查看次数

标签 统计

ios ×3

objective-c ×3

iphone ×2

c ×1

foundation ×1

python ×1

python-3.x ×1

xcode ×1