草庐IT

iphone - 是否可以通过 nsnotification 将数组作为 obj 传递

我可以通过使用协议(protocol)和委托(delegate)来做到这一点,但我想尝试使用NSNotification我的任务是通过通知将NSMutableArray从一个View发送到另一个View。是否可以做[[NSNotificationCenterdefaultCenter]postNotificationName:@"reloadData"object:myArray];然后,在接收器中,我怎样才能得到传递过来的myArray。我正在阅读并对通知对象的userInfo和object感到困惑。请就此问题向我提出建议。 最佳答案

objective-c - 从具有属性的 NSObject 转换为 NSDictionary 的 Obj-C 简单方法?

我遇到了一些我最终想通的事情,但认为可能有更有效的方法来完成它。我有一个对象(一个采用MKAnnotation协议(protocol)的NSObject),它有许多属性(标题、副标题、纬度、经度、信息等)。我需要能够将此对象传递给另一个对象,该对象希望使用objectForKey方法从中提取信息,作为NSDictionary(因为这是它从另一个ViewController获取的信息)。我最后做的是创建一个新的NSMutableDictionary并在其上使用setObject:forKey来传输每条重要信息,然后我只是传递新创建的字典。是否有更简单的方法来做到这一点?相关代码如下://

ios - Xcode 7,Obj-C, "Null passed to a callee that requires a non-null argument"

在Xcode7中,我收到此警告:Nullpassedtoacalleethatrequiresanon-nullargument..从这个NSMutableArray的nil初始化...sectionTitles=[[NSMutableArrayalloc]initWithObjects:nil];我发现我应该改用removeAllObjects。[sectionTitlesremoveAllObjects];但是,这不允许我计算sectionTitles.count==0。我确实尝试了sectionTitles==nil,但是除非我使用iniWithObjects,否则我以后无法添加

ios - 项目名为 "Foo does not contain a scheme named "Bar"bitrise.io

我只是在bitrise.io中配置了一个项目。但是xcode-build失败并出现错误:xcodebuild:error:Theprojectnamed"Foo"doesnotcontainaschemenamed"Bar".The"-list"optioncanbeusedtofindthenamesoftheschemesintheproject.我仔细检查了方案Bar确实存在于项目Foo 最佳答案 基于BryanMussial回答TherootcauseisthatthedefaultbehaviorofSchemesisto

redis - 如何获取 foo :* using a single id counter instead of a set/array 中的所有哈希值

介绍我的域有articles,其中有一个title和text.每篇文章都有revisions(就像SVN概念),所以每次更改/编辑时,这些更改将存储为revision.修订由changes组成和description这些变化我希望能够获得所有修订descriptions立刻。有什么问题?我确定我会存储revision作为articles:revisions:中的哈希存储changes,和description在里面。我不确定的是如何获得所有descriptions立刻。我有很多选择可以做到这一点,但没有一个能说服我。将文章的修订ID存储为一个集合,并使用SORTarticles:rev

objective-c - 在 Swift 中使用 obj-c typedef

我有一个typedef:typedefNSStringVMVideoCategoryType;externVMVideoCategoryType*constVMVideoCategoryType_MusicVideo;externVMVideoCategoryType*constVMVideoCategoryType_Audio;externVMVideoCategoryType*constVMVideoCategoryType_Performance;externVMVideoCategoryType*constVMVideoCategoryType_Lyric;externVMVi

swift - `guard let foo = foo` 什么时候合法的?

回到2016年11月,我发布了一个问题,询问为什么我不能使用guard创建一个使用与可选变量相同名称的变量的未包装版本,就像你可以使用iflet一样:链接:Whyisn'tguardletfoo=foovalid?当我写这个问题时,下面的代码将无法编译并出现“定义与先前值冲突”的错误://Testofusingguardtocreateanunwrappedversionofavar,likeifletfuncguardTest(_viewController:UIViewController?)->UIViewController?{//CheckifthecurrentviewCo

来自 AST 上下文 :"的 Swift "error: in auto-import: failed to get module ' foo'

使用以下设置(gist):Package.swift:importPackageDescriptionletpackage=Package(name:"foo",dependencies:[.Package(url:"https://github.com/rxwei/LLVM_C",majorVersion:1,minor:0)])生成文件:all:@swiftbuild\-Xcc-I`llvm-config--includedir`\-Xlinker-L`llvm-config--libdir`\-Xlinker-rpath-Xlinker`llvm-config--libdir`m

ios - 如何在 Swift 中使用扩展协议(protocol)公开 Obj-C 类的现有属性

在Swift1.1中,我们能够编译如下代码,并在我们通过扩展添加的协议(protocol)公开现有Objective-C属性的地方工作。我们还有一些属性由扩展处理。@objcprotocolEnableable:class{varenabled:Bool{getset}}letDisabledAlpha:CGFloat=0.5letEnabledAlpha:CGFloat=1.0extensionUIButton:Enableable{}extensionUIImageView:Enableable{varenabled:Bool{get{returnalpha>DisabledAlp

objective-c - SWIFT 3.0 迁移错误 - 通用 Obj-C 类的扩展无法在运行时访问该类的通用参数

我的这段代码在Swift2中运行良好。extensionPHFetchResult:Sequence{publicfuncmakeIterator()->NSFastEnumerationIterator{returnNSFastEnumerationIterator(self)}}自从我升级到Swift3ExtensionofagenericObjective-Cclasscannotaccesstheclass'sgenericparametersatruntime我不知道如何解决这个问题。非常感谢任何帮助! 最佳答案 此处报告