小编Ess*_*sse的帖子

xcode未知类型名称

我有这样的代码:

Match.h:

#import <Foundation/Foundation.h>
#import "player.h"

@interface Match : NSObject
{
    Player *firstPlayer;
}

@property (nonatomic, retain) Player *firstPlayer;

@end
Run Code Online (Sandbox Code Playgroud)

Player.h:

#import <Foundation/Foundation.h>
#import "game.h"
@interface Player : NSObject
{
}

- (Player *) init;

//- (NSInteger)numberOfPoints;
//- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil;


@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSString *surname;
@property (nonatomic, assign) NSInteger *player_id;
@property (nonatomic, retain) NSString *notes;

@end
Run Code Online (Sandbox Code Playgroud)

Game.h:

#import <Foundation/Foundation.h>
#import "match.h"
#import "player.h"

@interface Game : NSObject
{
    NSMutableArray *matches;
    NSMutableArray *players;
    NSString …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios

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

Ruby 2 中的 Translit 等效项(不带 iconv)

正如我们所知,我们可以Iconv在 Ruby 1.9.3 中使用TRANSLITflag,它将用 ASCII 等效项替换重音字符,前提是它们不存在于目标编码中

\n\n

使用示例:

\n\n
require \'iconv\'\nz = "H\xc3\xa5kan"\nIconv.conv("windows-1250//TRANSLIT", "UTF-8", z) \n# => outputs "Hakan" (with diactric removed)\npl = "za\xc5\xbc\xc3\xb3\xc5\x82\xc4\x87"\nIconv.conv("windows-1250//TRANSLIT", "UTF-8", pl)\n# => outputs "za\xc5\xbc\xc3\xb3\xc5\x82\xc4\x87" (because windows-1250 contains all this characters)\n# well, to be honest it outputs "za\\xBF\\xF3\\xB3\\xE6" because of terminal settings\n# but I hope you understand\n
Run Code Online (Sandbox Code Playgroud)\n\n

但是Iconv已被弃用,建议使用String#encode

\n\n

然而使用时#encode出现问题:

\n\n
z.encode(\'windows-1250\', \'utf-8\')\nEncoding::UndefinedConversionError: U+00E5 to WINDOWS-1250 in conversion from UTF-8 to WINDOWS-1250\n
Run Code Online (Sandbox Code Playgroud)\n\n …

ruby

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

我的Ruby程序打印对象的检查而不是定义的to_s方法

最后,当我尝试在我的ruby程序中添加splat并打印red_team时没有显示我传递的内容,但它显示了地址.

只需在终端上运行这段代码,您就会知道我在说什么.它告诉我这个

Power Rangers team: `#<Context::Player:0x0000000252c3d8>, #<Context::Player:0x0000000252c298>, #<Context::Player:0x0000000252c158>, #<Context::Player:0x0000000252c018>, #<Context::Player:0x0000000252bed8>`
Run Code Online (Sandbox Code Playgroud)

我的代码:

        class Player
            attr_accessor :name, :age, :skill_level

            def initialize (name, age, skill_level)
                @name = name
                @age = age
                @skill_level = skill_level
            end

            def to_s
                puts "<#{@name}: #{@skill_level}(SL), #{@age}(AGE)"
            end
        end

        class Team
            include Enumerable
            attr_accessor :name, :players

            def initialize (name)
                @name = name
                @players = []
            end

            def add_players (*players)
                @players += players
            end

            def to_s
                "#{@name} team: #{@players.join(', ')}"
            end

            def each
                @players.each  {|player| yield player}
            end
        end

        player1 …
Run Code Online (Sandbox Code Playgroud)

ruby

-2
推荐指数
1
解决办法
59
查看次数

标签 统计

ruby ×2

ios ×1

iphone ×1

objective-c ×1