编辑:我能够通过更改NSLog来呈现实际的int而不是指针来修复表示事物.
NSLog(@"id:%i",[[info valueForKey:@"idQ"] intValue]);
还有Cocoa错误1660来解决?
我正在使用Core Data进行我的第一次测试,并正在使用这个(http://www.raywenderlich.com/934/core-data-tutorial-getting-started)教程.
然后,我尝试了自己的测试,并取得了一些成功.但是,int32(因为教程只有32)导致一个奇怪的数字.我怀疑它与NSNumber有关.Cocoa错误1660我认为输出中的长数字有一些东西(输入= 1和输出= 95518976).我想这是一个成为指针的问题,需要正确呈现,但错误呢.
有人可以给我一个提示如何解决这个问题吗?
- (void)testingDBmodel {
NSLog(@">>testingDBmodel<<");
//=================DATABASE===================//
// id
// qDiff
// question
// qRightAnswer
// qWrongAnswer1
// qWrongAnswer2
// qNr
// qRegDate
if (managedObjectContext == nil) { managedObjectContext = [(FamQuiz_v2AppDelegate *)
[[UIApplication sharedApplication] delegate] managedObjectContext]; }
NSManagedObjectContext *context = [self managedObjectContext];
NSManagedObject *famQuizInfo = [NSEntityDescription
insertNewObjectForEntityForName:@"questions"
inManagedObjectContext:context];
[famQuizInfo setValue:[NSNumber numberWithInt:1] forKey:@"idQ"];
[famQuizInfo setValue:@"qDiff1" forKey:@"qDiff"];
[famQuizInfo setValue:@"question1" forKey:@"question"];
[famQuizInfo setValue:@"qRightAnswer1" forKey:@"qRightAnswer"];
[famQuizInfo setValue:@"qWrongAnswer1_1" forKey:@"qWrongAnswer1"];
[famQuizInfo setValue:@"qWrongAnswer2_2" forKey:@"qWrongAnswer2"];
[famQuizInfo setValue:@"999" forKey:@"qNr"];
[famQuizInfo …Run Code Online (Sandbox Code Playgroud) 我无法将addObject添加到'easyQArray'(NSMutableArray)中.当我在本地定义数组时它确实有效,但是当我将声明移动到.h文件中时它不再起作用了.
当我尝试访问不存在的数组中的索引时,应用程序崩溃了:
// Create question arrays
if (easyPlayers > 0) {
for (int XX = 0; XX < easyQuestions; XX++) {
[easyQArray addObject: [myArray objectAtIndex: easyQStartPos]];
NSLog(@"myArray: %@", [myArray objectAtIndex: easyQStartPos]);
NSLog(@"easyQArray: %@", easyQArray);
easyQStartPos = easyQStartPos + 1;
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
2010-12-28 15:52:57.636 XX_v2 [11582:207] myArray:205
2010-12-28 15:52:57.636 XX_v2 [11582:207] easyQArray :( null)
2010-12-28 15:52:57.636 XX_v2 [11582:207] myArray:71
2010-12-28 15:52:57.637 XX_v2 [11582:207] easyQArray :( null)
2010-12-28 15:52:57.637 XX_v2 [11582:207] myArray:94
2010 -12-28 15:52:57.638 XX_v2 [11582:207] easyQArray :( null)
2010-12-28 …
可能是一个非常简单的问题,我一直在寻找答案,但找不到它,可能是因为我还没有找到要问的问题.
我想要以下输出,请参阅输出中的'%'字符:
(33%)
我只是不明白如何格式化"%"字符,所以它在输出中可见.
txt2 = [txt2 stringByAppendingFormat:@"(%i)", percentage];
Run Code Online (Sandbox Code Playgroud)
我知道上面的stringByAppendingFormat是错误的.我非常感谢任何帮助.
我需要一些帮助来解决这个内存泄漏问题.我正在使用ARC.
潜在的泄漏就在这条线上:
NSURL *aFileURL = [NSURL fileURLWithPath:filePath isDirectory:NO];
Run Code Online (Sandbox Code Playgroud)
这是代码:
// === Check if the game should play sound === //
if (sound == YES) {
//==== PLAY THE LOOSING SOUND ====//
// Form a URL to the sound file, which in init using the Path
NSBundle *mainBundle = [NSBundle mainBundle];
NSString *filePath = [mainBundle pathForResource:@"wrong2" ofType:@"wav"];
NSURL *aFileURL = [NSURL fileURLWithPath:filePath isDirectory:NO];
// Create a sound ID,
SystemSoundID myID;
// Register the sound
AudioServicesCreateSystemSoundID((__bridge_retained CFURLRef)aFileURL, &myID) ;
// Play the …Run Code Online (Sandbox Code Playgroud) 我是Core Plot的新手,我无法在我的视图中添加一个Legend.我一直在尝试各种教程并阅读大量信息,但我不明白如何显示图例.
我真的很感激一些帮助,因为我花了很多时间试图让它发挥作用.
请注意,我在这一点上的目标是显示如下传奇:

这是我得到的:

唯一出现的是右边的粗线.我可以移动,但不能得到传说.
代码:
// Create pieChart from theme
pieChart = [[CPTXYGraph alloc] initWithFrame:CGRectZero];
CPTTheme *theme = [CPTTheme themeNamed:kCPTDarkGradientTheme];
[pieChart applyTheme:theme];
//Create host view
self.hostingView = [[CPTGraphHostingView alloc]
initWithFrame:[[UIScreen mainScreen]bounds]];
[self.view addSubview:self.hostingView];
hostingView_.hostedGraph = pieChart;
pieChart.axisSet = nil;
pieChart.plotAreaFrame.borderLineStyle = nil;
pieChart.paddingLeft = 10.0;
pieChart.paddingTop = 120.0;
pieChart.paddingRight = 10.0;
pieChart.paddingBottom = 80.0;
pieChart.fill = [CPTFill fillWithColor:[CPTColor clearColor]];
pieChart.plotAreaFrame.fill = [CPTFill fillWithColor:[CPTColor clearColor]];
CPTMutableTextStyle *whiteText = [CPTMutableTextStyle textStyle];
whiteText.color = [CPTColor whiteColor];
whiteText.fontSize = 14;
whiteText.fontName = …Run Code Online (Sandbox Code Playgroud) 我刚刚开始学习Unity3D javascript,这是我第一次尝试学习,试图复制一个洗牌的Objective-C代码片段,我有以下代码:
function Shuffle(theCardArray : Array) {
var dupeArray = new Array();
var count = theCardArray.length;
print("theCardArray: " + theCardArray);
dupeArray = theCardArray;
count = dupeArray.length;
print("A) Count dupeArray: " + count);
print("B) Count dupeArray: " + dupeArray.length);
theCardArray.Clear();
for (var i = 0; i < count; i++) {
// Select random element between i and the end of the array to swap it
var nElements = count - i;
var n = Random.Range(0, nElements);
print("#1");
print("C) Count dupeArray: " …Run Code Online (Sandbox Code Playgroud) 我知道以前有人问过这个问题,我已经检查了答案,但仍然有问题。我需要更新我的 XCODE 游戏,它是用 Objective-C 编写的,以便将它保存在 AppStore 中,而且我已经好几年没有主动接触 OBC 了。我已经能够解决除 UIPopoverController 问题之外的所有其他问题。
我在代码中用“>”标记了警告。
我真的很感激这里的一些帮助。
我有以下代码:
#import "DetailViewController.h"
@interface DetailViewController ()
>>@property (strong, nonatomic) UIPopoverController *masterPopoverController;
- (void)configureView;
@end
@implementation DetailViewController
@synthesize detailItem = _detailItem;
@synthesize detailDescriptionLabel = _detailDescriptionLabel;
>>@synthesize masterPopoverController = _masterPopoverController;
#pragma mark - Managing the detail item
- (void)setDetailItem:(id)newDetailItem
{
if (_detailItem != newDetailItem) {
_detailItem = newDetailItem;
// Update the view.
[self configureView];
}
>>if (self.masterPopoverController != nil) {
>> [self.masterPopoverController dismissPopoverAnimated:YES];
>>}
}
- (void)configureView
{
// …Run Code Online (Sandbox Code Playgroud) 我正在加载一个文件,并希望在UIProgressView中显示进度.我可以设置初始值:
[loadingProgressView setProgress: 0.00];
Run Code Online (Sandbox Code Playgroud)
..in viewDidLoad这完美无缺.
我唯一要做的就是在每个循环中向条添加0.1,但它不会更新:
while (eOF != 99999) {
...
[loadingProgressView setProgress:loadingProgressView.progress + 0.10];
}
Run Code Online (Sandbox Code Playgroud)
我已经检查过,但每次循环时都没有真正找到任何更新栏的内容.
有人可以就此分享一些建议吗?
--- UPDATE ---
尝试了这个没有成功:
while (eOF != 99999) {
...
[loadingProgressView setProgress:loadingProgressView.progress + 0.10];
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate date]];
}
Run Code Online (Sandbox Code Playgroud) 我在网上搜索了答案并找到了不少解决方案,但不得不承认我并不理解,因为我很新,如何应用答案,一个例子是:UIDevice uniqueIdentifier已弃用 - 现在该怎么办?
我真的很感激,如果有人可以向我展示如何在下面的代码中将解决方案应用于该问题的示例,因为不推荐使用以下行(uniqueIdentifier),代码行来自Cocos2d CLScoreServerRequest.m,但是在其他几个中出现了好:
device = [[UIDevice currentDevice] uniqueIdentifier];
Run Code Online (Sandbox Code Playgroud)
该功能如下:
-(BOOL) requestScores:(tQueryType)type
limit:(int)limit
offset:(int)offset
flags:(tQueryFlags)flags
category:(NSString*)category
{
// create the request
[receivedData setLength:0];
// it's not a call for rank
reqRankOnly = NO;
NSString *device = @"";
if( flags & kQueryFlagByDevice )
device = [[UIDevice currentDevice] uniqueIdentifier];
// arguments:
// query: type of query
// limit: how many scores are being requested. Default is 25. Maximun is 100
// offset: offset of the scores
// flags: bring …Run Code Online (Sandbox Code Playgroud) 我一直试图解决这个问题,但没能这样做.我也无法在网上找到任何好的例子.
我已经尝试过rowHeightsThatFit:但是不要让它工作.
我想在一行上列出底层传说,确保它被看到.

objective-c ×8
iphone ×4
core-plot ×2
core-data ×1
ios ×1
javascript ×1
memory-leaks ×1
unityscript ×1
xcode ×1