基本上,应用IM工作的,如果用户没有滚动到他们的相机胶卷的最底部得到他们最近的照片,我想在顶部最近的,不会这将是一个痛苦的少了很多反正有意义吗?不知道为什么苹果这样设计,或者我只是没有意识到什么.
谢谢
缺口
只是想知道,它似乎工作得很好,但我想确保我使用普遍接受的编码实践,而不是养成坏习惯.
谢谢,
缺口
我正在将应用程序从iOS端移植到Mac端,并且我遇到了令人讨厌的链接错误,其中链接器似乎正在尝试使用iOS版本的coredata框架而不是(x86_64)框架.我删除了框架并重新添加它,并知道我正在添加mac版本.我也重新生成了我的模型类.我收到这个错误:
ld: warning: ignoring file /Users/xxxxx/xcode_projects/xxxxx/CoreData.framework/CoreData, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols for architecture x86_64:
"_NSSQLiteStoreType", referenced from:
-[CoreDataSingleton persistentStoreCoordinator] in CoreDataSingleton.o
"_NSInferMappingModelAutomaticallyOption", referenced from:
-[CoreDataSingleton persistentStoreCoordinator] in CoreDataSingleton.o
"_NSMigratePersistentStoresAutomaticallyOption", referenced from:
-[CoreDataSingleton persistentStoreCoordinator] in CoreDataSingleton.o
"_OBJC_CLASS_$_NSManagedObjectContext", referenced from:
objc-class-ref in CoreDataSingleton.o
"_OBJC_CLASS_$_NSManagedObjectModel", referenced from:
objc-class-ref in CoreDataSingleton.o
etc...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see …
Run Code Online (Sandbox Code Playgroud) 我正在编写"在客观c 2.0中编程"一书,我不明白为什么这个程序不起作用.基本上我需要建立一个程序,将华氏温度值转换为celcius值.
我想,只是解决这个问题很简单没有对象,只需使用一条直线程序方法,任何办法,我遇到的问题是,该变量的值我定义代表华氏或摄氏值都上来了一种随机的.
这是我的代码:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
float fahrenheit;
float celciusConverted;
fahrenheit = 27.0;
celciusConverted = ( fahrenheit - 32 ) / 1.8 ;
NSLog(@"%f degrees fahrenheit is equal to %f degrees celcius") , fahrenheit, celciusConverted;
[pool drain];
return 0;
}
Run Code Online (Sandbox Code Playgroud) 嘿,在一些类别上工作,我遇到了一个奇怪的问题,我基本上扩展了一个计算器类来添加一些trig方法,当我在返回时调用sin方法时,我得到的值不正确一双.我发送一个100.7的值到该方法,它返回0.168231,从我可以看到正确的值应该是= 0.939693或那里.
下面是代码,我还在这里附加了一个完整项目的链接:
(谢谢)
http://files.me.com/knyck2/svpfd4
//
// Calculator_trig.m
// 11.4_calculator_trig
//
// Created by Nicholas Iannone on 1/6/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "Calculator_trig.h"
#import <math.h>
@implementation Calculator (Trigonometry)
-(double) sin
{
double result;
result = (double) sin (accumulator);
return result;
}
-(double) cos
{
double result;
result = cos ( accumulator);
return result;
}
-(double) tan
{
double result;
result = tan ( accumulator);
return result;
}
@end
#import "Calculator.h"
@implementation Calculator
-(void) setAccumulator: (double) …
Run Code Online (Sandbox Code Playgroud) 所以我重写了dealloc方法,因为该对象是一个由另一个对象组成的复合对象.
我原来有这种dealloc方法:
-(id) dealloc; // Override to release the Rectangle object’s memory
{
[rect release];
[super dealloc];
return self;
}
Run Code Online (Sandbox Code Playgroud)
看完这本书后,我看到了另一个答案:
{
[rect release];
return [super dealloc];
}
Run Code Online (Sandbox Code Playgroud)
只是想知道两者是否同样有效.
谢谢,
缺口
我看到了这个帖子,但想确认一下:
因此,基本上任何时候你想要处理这些对象,你必须解压他们的ivars,然后将它们打包回新的对象,大概是NSNumbers?
这看起来很弱(背面有很大的疼痛,没有?).
你们这些人如何使用这些?
你避开它们吗?对它们进行子类化?有可变版本吗?
这似乎是很多工作来处理它们,很想听听它们的好处以及更有经验的程序员使用它们的方式,或者他们用来避免使用它们的策略.
谢谢,
缺口
我以前遇到过这个问题,但是到目前为止我能够解决这个问题,基本上我正在创建一个自定义UI按钮,将其图像设置为uiimage,然后在我使用下面的代码之前有一个标签的按钮现在丢失了它的标签.我需要该标签,因为它是以编程方式在后面的代码中设置的.
NSString *imageName = [NSString stringWithFormat:kNameOfButtonimage ];
UIImage *image = [UIImage imageNamed:imageName];
[button setImage:image forState:UIControlStateNormal ];
Run Code Online (Sandbox Code Playgroud)
任何你可以借出的帮助都会非常感激.
-缺口
所以我想这样做:
switch (keyPath) {
case @"refreshCount":
//do stuff
case @"timesLaunched":
//do other stuff
}
Run Code Online (Sandbox Code Playgroud)
但显然你只能使用整数作为开关数量.唯一的方法是将字符串解析为整数标识符然后运行switch语句吗?
像这样:
nsinteger num = nil;
if (keyPath isEqual:@"refreshCount") {
num = 0
}
if (keyPath isEqual:@"timesLaunched") {
num = 1
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试尽可能快地优化此代码,因为它会经常被调用.
谢谢,
缺口
注意:是的我正在使用KVO,所以我在"回调"中收到一个字符串.
注意#2:那么是什么让我首先考虑switch语句是我原来的代码实现是这样的:
if ([keyPath isEqual:@"refreshCount"] && ([[change valueForKey:@"new"] intValue] == 10)) { //
NSLog(@"achievemnt hit inside");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"title" message:@"Achievement Unlocked!" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:nil];
[alert show];
Run Code Online (Sandbox Code Playgroud)
我想在同一个方法中用不同的XX值做一堆这些:
if ([keyPath isEqual:@"refreshCount"] && ([[change valueForKey:@"new"] intValue] == 10)) {
//unlock …
Run Code Online (Sandbox Code Playgroud) 在我阅读的书中看到了这个例子,它对我来说根本没有意义,我可能错过了一些东西,但似乎你用值'10'分配计数,然后是值'x',这是不均匀的一个int.只是想知道这是否是有效的语法.
这本书说:
变量count和x以正常方式声明为整数变量.在下一行,变量intPtr被声明为"指向int的指针".请注意,这两行声明可以组合成一行:
int count = 10, x, *intPtr;
Run Code Online (Sandbox Code Playgroud)
这是程序取自:
#import <Foundation/Foundation.h>
int main (int argc, char *argv[ ])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int count = 10, x;
int *intPtr;
intPtr = &count;
x = *intPtr;
NSLog (@"count = %i, x = %i", count, x);
[pool drain];
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我知道您可以将所有键添加到数组中并将其添加到字典的一侧但我很好奇如何在字典中的某个点添加或插入值.我现在拥有它的方式我相信它只是不断覆盖最后的条目以便为新的条目腾出空间:
NSMutableDictionary *bookmarks = [[NSMutableDictionary alloc] init];
NSString *keyA = @"Stanford University";
NSString *keyB = @"Apple";
NSString *keyC = @"cs193p.com";
NSString *keyD = @"Stanford on iTunes";
NSString *keyE = @"Stanford Mail";
NSString *surlA = @"http://www.stanford.edu";
NSString *surlB = @"http://www.apple.com";
NSString *surlC = @"http://www.cs193p.stanford.edu";
NSString *surlD = @"http://www.itunes.stanford.edu";
NSString *surlE = @"http://www.stanfordshop.com";
NSURL *urlA;
urlA = [NSURL URLWithString:surlA];
NSURL *urlB;
urlA = [NSURL URLWithString:@"http://www.apple.com"];
[bookmarks setValue:urlA forKey: keyA];
[bookmarks setObject:urlB forKey: keyB];
//[bookmarks setObject:urlC forKey: keyC];
//[bookmarks setObject:urlD forKey: keyD];
//[bookmarks …
Run Code Online (Sandbox Code Playgroud) 基本上我正在寻找将xml变成nsdictionary层次结构的东西.
objective-c ×8
iphone ×5
ios ×2
macos ×2
xcode ×2
c ×1
calculator ×1
camera ×1
class ×1
cocoa-touch ×1
coding-style ×1
core-data ×1
dealloc ×1
key-value ×1
linker ×1
nsnumber ×1
oop ×1
textlabel ×1
trigonometry ×1
uibutton ×1
uiview ×1
web-services ×1
xml-parsing ×1