我正在编写一个应用程序来审查拉丁动词变位,但我遇到了障碍。我创建了一个结尾数组,但是当我尝试NSDictionary
用这些结尾初始化 an 时,count
字典的 the 始终为 0。我做错了什么?
这是BlackBox.h
:
#import <Foundation/Foundation.h>
@interface BlackBox : NSObject
@property (weak) NSDictionary *setOfEndings;
- (void)determineEndingsToUse;
@end
这是来自的相关方法BlackBox.m
:
- (void)determineEndingsToUse
{
NSArray *keys=[[NSArray alloc] initWithObjects:@"first person singular", @"second person singular", @"third person singular", @"first person plural", @"second person plural", @"third person singular", nil];
NSArray *endingsPossible = [[NSArray alloc] initWithObjects:@"ō", @"ās", @"at", @"āmus", @"ātis", @"ant", nil];
NSLog(@"endingsPossible count: %d", endingsPossible.count); //This logs 6, correctly.
if (!self.setOfEndings)
{
self.setOfEndings = [[NSDictionary alloc] initWithObjects:endingsPossible forKeys:keys];
}
NSLog(@"setOfEndings count: %d",self.setOfEndings.count); //This logs 0 instead of 6. Why?
}
有什么想法吗?