我已经使用CocoaPods将GitHub的Mantle项目添加到iOS 6项目中:
$ pod search Mantle
$ vim Podfile // here I added pod 'Mantle'
$ pod install // this installs Mantle 1.0
Run Code Online (Sandbox Code Playgroud)
然后我在自定义搜索路径之前将($inherited)变量添加到Header Search Paths项目的"构建设置"部分.当导入Mantle头文件Xcode抱怨时
#import "Mantle.h" // => 'Mantle/MTLJSONAdapter.h' file not found
Run Code Online (Sandbox Code Playgroud)
我错过了一步吗?我也安装了其他吊舱(AFNetworking和SSKeychain)但只有Mantle给我提出了问题.
我还添加了SSToolkit,但是按照"入门"的说明,即不使用CocoaPods.
我有一个Web服务,它返回一个对象的JSON,并在该对象中有一个其他对象的列表.我怎样才能让Mantle为这些嵌套对象中的每一个创建一个对象,而不是为每个嵌套对象提供一个字典?
使用UIAppearance代理设置UIBarButtonItem的子类的自定义属性会导致"无法识别的选择器"异常,因为设置器可能正由UIAppearance转发到UINavigationButton,而不是条形按钮本身.
我正在使用带有Xcode 5 DP5的iOS 7 Beta 5 SDK.但请不要告诉我它是在NDA之下,因为我不会在这个问题上讨论任何新功能或新类.我告诉你我的SDK,因为可以发现它只是测试版软件中的一个错误.
我将a子类化UIBarButtonItem并在头文件中创建了一个自定义属性:
@property (nonatomic, strong) NSString *mySubclassedProperty UI_APPEARANCE_SELECTOR;
Run Code Online (Sandbox Code Playgroud)
我的二传手和吸气器看起来像这样:
- (void)setMySubclassedProperty:(NSString *)mySubclassedProperty {
_mySubclassedProperty = mySubclassedProperty;
NSLog(@"%p %s %@", self, __PRETTY_FUNCTION__, mySubclassedProperty);
}
Run Code Online (Sandbox Code Playgroud)
没什么特别的,对吧?但它根本不起作用UIAppearance.当我尝试在我的应用程序的委托中设置默认外观时,它没有给我任何错误,也没有任何警告.
[[AKBarButtonItem appearance] setMySubclassedProperty:@"GLOBALLY ASSIGNED"];
Run Code Online (Sandbox Code Playgroud)
这似乎是工作就像一个魅力,除了使用它崩溃时,我尝试设置的一个实例的事实AKBarButtonItem来self.navigationItem.rightBarButtonItem:
self.navigationItem.rightBarButtonItem = [[AKBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:nil action:nil];
Run Code Online (Sandbox Code Playgroud)
回溯看起来像这样:
2013-08-13 14:30:08.551 UIBarButtonItem Subclass Demo[1512:a0b] -[UINavigationButton setMySubclassedProperty:]: unrecognized selector sent to instance 0x8c42710
2013-08-13 14:30:08.556 UIBarButtonItem Subclass Demo[1512:a0b] *** Terminating app due to uncaught …Run Code Online (Sandbox Code Playgroud) iphone uibarbuttonitem ios unrecognized-selector uiappearance
我需要一点帮助来转换它
MIDIDeviceRef midiDevice = MIDIGetDevice(i);
NSDictionary *midiProperties;
MIDIObjectGetProperties(midiDevice, (CFPropertyListRef *)&midiProperties, YES);
NSLog(@"Midi properties: %d \n %@", i, midiProperties);
Run Code Online (Sandbox Code Playgroud)
迅速.我有这个,但我正忙着投出CFPropertList.
var midiDevice = MIDIGetDevice(index)
let midiProperties = NSDictionary()
MIDIObjectGetProperties(midiDevice, CFPropertyListRef(midiProperties), 1);
println("Midi properties: \(index) \n \(midiProperties)");
Run Code Online (Sandbox Code Playgroud)
任何帮助都会很棒.
谢谢
我的核心数据应用程序中有一个奇怪的问题.
我的应用程序中有三个实体,但今天我发现其中一个实体存在问题.我的有问题的实体被调用Invoice,它有许多属性,包括Products.它编码NSDrray的NSArray(通过默认的NSValueTransformer).
一切正常 - 我创建我的发票,客户,产品等.一切正常.
但是,当我从列表中选择发票然后尝试编辑其产品并单击"保存"按钮时,我的保存仅在我的应用程序终止之前有效.
问题只出在我的products阵列上 - 其余的(例如付款日期,客户等)保存.
我在做什么
我通过我的Invoice对象
NSManagedObject *inv = [self.fetchedResultsController objectAtIndexPath:indexPath];
invoiceEditor.invoice = inv;
Run Code Online (Sandbox Code Playgroud)
并保存我的数据(在我的InvoiceEditorVC中):
[self.invoice setValue:client forKey:@"Client"] // NSDictionary;
[self.invoice setValue:products forKey:@"Products"] // NSArray of NSDictionaries;
[self.invoice setValue:pmDate forKey:@"PaymentDate"] // NSDate;
// other attributes
NSManagedObjectContext *context = self.invoice.managedObjectContext;
NSError *error = nil;
if (![context save:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
Run Code Online (Sandbox Code Playgroud)
Everythings一直保存到终止:客户,产品,日期.但只有产品在终止后才会"重置".
任何人?
我正在制作我的应用程序支持网站的移动版本,我在这里有一点WebKit/iOS/HTML/CSS问题...
我有一个页面index.php,附带mobile.css文件.在我的<head>标签中,我有:
<meta name="viewport" content="width=device-width, user-scalable=no, max-scale=1.0" />
Run Code Online (Sandbox Code Playgroud)
我body的css:
body {
font-family:"HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue","Helvetica","Lucida Grande",Verdana,Arial,sans-serif;
margin: 0;
background: url(../../images/textured_bg.png) repeat;
color:#454545;
font-size: 14px;
text-shadow: rgba(255, 255, 255, 0.5) 0 1px;
width:100%;
}
Run Code Online (Sandbox Code Playgroud)
一切都在纵向方向很好,但当我将我的iPhone旋转到横向时,Safari会缩放我的内容,使其看起来像是肖像,但更大一些:

我的问题:有没有办法,不为每个方向制作自定义CSS,强迫Safari不扩展我的内容?
我正在为我的应用程序(通过iCloud)制作备份管理器.我做了一些测试,基础工作正常.但几天后它停了下来.我正在NSMetadataQuery用于搜索是否存在备份文件.我的备份文件被命名为例如Backup29112011154133.xml其中数字代表备份日期(格式为ddMMyyyyHHmmss).我检查一下-viewDidAppear:
- (void)viewDidAppear:(BOOL)animated {
[self checkForRemoteFile];
}
- (void)checkForRemoteFile {
NSURL *ubiq = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
if (ubiq) {
NSMetadataQuery *query = [[NSMetadataQuery alloc] init];
[query setSearchScopes:[NSArray arrayWithObject:NSMetadataQueryUbiquitousDocumentsScope]];
NSPredicate *pred = [NSPredicate predicateWithFormat:@"%K like 'Backup*'",NSMetadataItemFSNameKey];
[query setPredicate:pred];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryDidFinishGathering:) name:NSMetadataQueryDidFinishGatheringNotification object:query];
[query startQuery];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"iCloud is unavailable at the moment" message:nil delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil];
[alert setTag:TAG_ALERT_NOICLOUD];
[alert show];
}
}
- (void)queryDidFinishGathering:(NSNotification *)notif …Run Code Online (Sandbox Code Playgroud) 我现在正在创建一个站点,我需要为<pre>带有语法高亮和行号的标签提供支持(我正在使用GitHub Gists,但这没关系).
问题是,我的网站响应,我不能指定一个静态width属性我 <pre>的<td>,因为表可以调整.
如果你想看一个实例,这里是我创建的例子,向你展示我在说什么:http://jsfiddle.net/akashivskyy/jNRrn/.
如果你不想搬到任何地方,这里有一个简短的解释......
我的基本树看起来像这样:
<div class="file">
<table class="source">
<tr>
<td class="lines">
<span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
</td>
<td class="code">
<pre>NSString *title = @"Title";
NSString *title2 = [title stringByAppendingString:@"This is a very very long string"];
NSLog(@"%@", title2);</pre>
</td>
</tr>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
而且很基本的CSS:
.file {
overflow: hidden;
width:340px;
}
td.code pre {
overflow: auto;
}
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为<pre>没有width财产.我设法以某种方式允许滚动的唯一方法是申请overflow: auto我的.file …
这是我的理解
var perhapsInt : Int?
Run Code Online (Sandbox Code Playgroud)
这会自动设置为一个.None值.以下代码片段确认(没有编译器错误)
class MyClass {
var num1: Int = 0
var num2: Int?
init(num1: Int) {
self.num1 = num1
}
}
var newClass = MyClass(num1: 5)
newClass.num1 // prints '5'
newClass.num2 // prints 'nil'
Run Code Online (Sandbox Code Playgroud)
我对可选的初始化过程的理解是否正确?如果是这样,为什么当我换num2到时这不起作用let.
我期待nil使用时可选项默认的相同行为let.我在这里错过了什么吗?
class MyClass {
var num1: Int = 0
let num2: Int?
init(num1: Int) {
self.num1 = num1
// compiler error : return from initialiser without initialising all stored properties
} …Run Code Online (Sandbox Code Playgroud) 我正在完成我的核心数据应用程序和我开始我的最终测试.
Everyfing工作正常,除了一件事,随机发生,我无法重现它.
这是日志(使用NSZombieEnabled):
2011-07-03 20:27:53.144 MYAPP[1882:707] -[__NSCFType controllerWillChangeContent:]: unrecognized selector sent to instance 0x4a4c490
2011-07-03 20:27:53.149 MYAPP[1882:707] Serious application error. Exception was caught during Core Data change processing. This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification. -[__NSCFType controllerWillChangeContent:]: unrecognized selector sent to instance 0x4a4c490 with userInfo (null)
2011-07-03 20:27:53.165 MYAPP[1882:707] CoreAnimation: ignoring exception: -[__NSCFType controllerWillChangeContent:]: unrecognized selector sent to instance 0x4a4c490
Run Code Online (Sandbox Code Playgroud)
它在这里崩溃:
NSManagedObjectContext *context = [(AppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext]; // IT'S OK
NSManagedObject *newManagedObject = …Run Code Online (Sandbox Code Playgroud) iphone core-data nsfetchedresultscontroller nsmanagedobjectcontext
iphone ×5
ios ×3
core-data ×2
css ×2
objective-c ×2
swift ×2
cocoapods ×1
html ×1
html-table ×1
icloud ×1
init ×1
ios5 ×1
macos ×1
optional ×1
orientation ×1
overflow ×1
pre ×1
uiappearance ×1