English 中文(简体)
你们怎样加入国家出口管制局,把[数量编号WithChar:c] s入国家情报区?
原标题:How do you join an NSArray of [Number numberWithChar: c] s into an NSString?

当我使用<代码>componentsJoinedByString时,我刚刚获得长篇数字。

Edit:我认识到这项任务令人困惑。 为什么有人在地球上用NSNumber为国家航空航天局居住,如果他们想要国家空间安全局的话? 答案是,我写出一个轻松的单位试验框架。 基本功能genNum,genBoolgen Char 分别产生无照的NSNumbers、BOOL和char价值。 然后有<代码>genArray,使用特定发电机生成随机阵列。 因此,将使用<代码>gen Array,使用<代码>gen Char generator, and transform the subsequently NSArray into an NSString.

特性仅作为<代码>储存。 NSNumbers und char/code>s due to a technicality:genArray>/code>take a group and calls the/2005/4 100-oddtime to populatione the NSArray. 禁区必须持有奥杰克目标,而不是原始类型。

因此,问题依然存在: 你们如何加入国家出口管制局(NSNumber number WithChar: c)进入国家安保局。

最佳回答
+ (NSString *) genString {
    NSArray* arr = [self genArray: ^() { return [ObjCheck genChar]; }];

    NSMutableString* s = [NSMutableString stringWithCapacity: [arr count]];

    int i;
    for (i = 0; i < [arr count]; i++) {
        [s appendString: [NSString stringWithFormat: @"%c", [[arr objectAtIndex: i] charValue]]];
    }

    return s;
}
问题回答

<代码>componentsJoinedByString将阵列要素并入显示它们之间的分离特性。 阵列元素将使用<条码>说明/代码>方法转换成方体(如果还没有<条码>NSString)。 如果有<代码>。 NSNumbers 我预计会有令人感兴趣的结果。

为什么不能用<代码>填满你的阵列。 缩略语 WithCharacters:c length:1]? 然后,<代码>componentsJoinedByString:就应当工作。 (见stringWithCharacters:length:;以上仅供参考。) 例如,您可能必须使用<代码>&c。

+ (id)genString {
    NSArray *chars = [self genArray:^{ return [ObjCheck genChar]; }];

    if ([chars count] == 0) {
        return @"";
    }

    unichar *buffer = malloc(sizeof(unichar) * [chars count]);

    [chars enumerateObjectsUsingBlock:^(NSNumber *num, NSUInteger idx, BOOL *stop) {
        buffer[idx] = (unichar)[num charValue];
    }];

    return [[[NSString alloc] initWithCharactersNoCopy:buffer length:[chars count] freeWhenDone:YES] autorelease];
}

这一特殊解决办法将假设果园;127 应被视为单条编码点(基本上是指作为ISO-8859-1)的果园价值。 它还避免在制造由此造成的扼杀时复制缓冲。





相关问题
Asynchronous request to the server from background thread

I ve got the problem when I tried to do asynchronous requests to server from background thread. I ve never got results of those requests. Simple example which shows the problem: @protocol ...

objective-c: Calling a void function from another controller

i have a void, like -(void) doSomething in a specific controller. i can call it in this controller via [self doSomething], but i don t know how to call this void from another .m file. I want to call ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

NSUndoManager and runModalForWindow:

I have a simple Core Data app which displays a list of entities in the main window. To create or add new entities, I use a second modal window with a separate managed object context so changes can be ...

NSMutableArray values becoming "invalid"

I m trying to show a database information in a tableview and then the detailed information in a view my problem is as follow: I created a NSMutableArray: NSMutableArray *myArray = [[NSMutableArray ...

iPhone numberpad with decimal point

I am writing an iPhone application which requires the user to enter several values that may contain a decimal point (currency values, percentages etc.). The number of decimal places in the values ...

热门标签