nsobject

Value of type 'User' has no subscripts

吃可爱长大的小学妹 提交于 2020-07-23 06:41:21
问题 I am trying to create a UITableView on my IOS app that displays a list of all the app's registered users from Firebase and includes a UISearchBar to search through them. I am very new to this and unfortunately this code is giving me the following error: "Value of type 'User' has no subscripts" on the line of code "let user = users[indexPath.row]" There is an NSObject User class in another file that defines name and email as String? These are the variables: var searchActive : Bool! var

Value of type 'User' has no subscripts

丶灬走出姿态 提交于 2020-07-23 06:40:53
问题 I am trying to create a UITableView on my IOS app that displays a list of all the app's registered users from Firebase and includes a UISearchBar to search through them. I am very new to this and unfortunately this code is giving me the following error: "Value of type 'User' has no subscripts" on the line of code "let user = users[indexPath.row]" There is an NSObject User class in another file that defines name and email as String? These are the variables: var searchActive : Bool! var

Value of type 'User' has no subscripts

蓝咒 提交于 2020-07-23 06:39:30
问题 I am trying to create a UITableView on my IOS app that displays a list of all the app's registered users from Firebase and includes a UISearchBar to search through them. I am very new to this and unfortunately this code is giving me the following error: "Value of type 'User' has no subscripts" on the line of code "let user = users[indexPath.row]" There is an NSObject User class in another file that defines name and email as String? These are the variables: var searchActive : Bool! var

多线程&NSObject&NSThread&NSOperation&GCD

心已入冬 提交于 2020-05-05 12:13:15
1、NSThread 每个NSThread对象对应一个线程,量级较轻(真正的多线程) 以下两点是苹果专门开发的“并发”技术,使得程序员可以不再去关心线程的具体使用问题 2、NSOperation/NSOperationQueue 面向对象的线程技术 3、GCD —— Grand Central Dispatch(派发) 是基于C语言的框架,可以充分利用多核,是苹果推荐使用的多线程技术 以上这三种编程方式从上到下,抽象度层次是从低到高的,抽象度越高的使用越简单,也是Apple最推荐使用的。但是就目前而言,iOS的开发者,需要了解三种多线程技术的基本使用过程。因为很多框架技术分别使用了不同多线程技术。 NSThread: 优点:NSThread 比其他两个轻量级,使用简单 缺点:需要自己管理线程的生命周期、线程同步、加锁、睡眠以及唤醒等。线程同步对数据的加锁会有一定的系统开销 NSOperation: 不需要关心线程管理,数据同步的事情,可以把精力放在自己需要执行的操作上 NSOperation是面向对象的 GCD: Grand Central Dispatch是由苹果开发的一个多核编程的解决方案。iOS4.0+才能使用,是替代NSThread, NSOperation的高效和强大的技术 GCD是基于C语言的 NSObject的多线程方法——后台线程 (void

Swift compile error when subclassing NSObject and using generics

安稳与你 提交于 2020-01-22 17:23:33
问题 The following Swift code generates a compile error at build time: import Foundation class Wrapper<T> : NSObject { let obj : T init(x : T) { self.obj = x } } Am I doing something wrong or is this a compiler bug? If so, what could I do to work around it? The error log: CompileSwift normal i386 com.apple.xcode.tools.swift.compiler cd /Users/hermespique/workspace/HanekeSwift export PATH="/Applications/Xcode6-Beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:

What happens if i call nsobject init more than once? Does it increase retain count?

孤街浪徒 提交于 2020-01-14 10:37:32
问题 I'm pretty new to Objective-C and i have lots of troubles with memory management and still i understand a little. If i have an object, NSArray * myArray for example, and i do this myArray = [[NSArray alloc] initWithObjects:obj1,obj2,obj3,nil]; then i'm doing something and i want myArray to contain new objects and then i init it again [myArray initWithObjects:obj4,obj5,obj6, nil]; seems like it does what i need but is it correct grom the point of view of memory management?does it increase

How to add pointer to an NSObject custom subclass to an NSMutableArray?

僤鯓⒐⒋嵵緔 提交于 2020-01-14 03:22:05
问题 For the following code snippet from ViewController.m: - (IBAction)buttonAction:(id)sender { CustomButton *button = (CustomButton *)sender; button.associatedObject = [self.sourceOfObjects.objectArray lastObject]; [self.foo.arrayOfObjects addObject:button.associatedObject]; // this does not work? } • CustomButton is subclass of UIButton and has @property (nonatomic, strong) associatedObject that is a pointer to an object of type NSObject. • sourceOfObjects is a @property (nonatomic, strong) of

Swift : '(NSObject, AnyObject)' does not have a member named 'subscript'

橙三吉。 提交于 2020-01-11 08:35:07
问题 I'm trying to extract the badge value out of the userInfo dictionary of a remote notification. I read many post and found a solution of my problem but I'm highly not satisfied! So here is my data structure (I removed the useless lines): { aps = { badge = 7 } } To extract this number '7' out of my userInfo I would like to do the following: self.updateAppIcon(userInfo["aps"]["badge"] as? Int) But of course I get the following error : Swift : '(NSObject, AnyObject)' does not have a member named

AVAudioPlayer Object Sound Not Playing - Swift

為{幸葍}努か 提交于 2020-01-05 08:11:45
问题 I have created an object class of AVAudioPlayer below in order to play a noise: class MusicAudio: NSObject, AVAudioPlayerDelegate { var bassAudio : AVAudioPlayer! = AVAudioPlayer() override init() { super.init() let bassAudioPath = NSBundle.mainBundle().pathForResource("Raw", ofType:"mp3") let fileURL = NSURL(fileURLWithPath: bassAudioPath!) bassAudio = AVAudioPlayer(contentsOfURL: fileURL, error: nil) bassAudio.currentTime = 0 bassAudio.volume = 1.0 bassAudio.delegate = self } func

AVAudioPlayer Object Sound Not Playing - Swift

给你一囗甜甜゛ 提交于 2020-01-05 08:11:09
问题 I have created an object class of AVAudioPlayer below in order to play a noise: class MusicAudio: NSObject, AVAudioPlayerDelegate { var bassAudio : AVAudioPlayer! = AVAudioPlayer() override init() { super.init() let bassAudioPath = NSBundle.mainBundle().pathForResource("Raw", ofType:"mp3") let fileURL = NSURL(fileURLWithPath: bassAudioPath!) bassAudio = AVAudioPlayer(contentsOfURL: fileURL, error: nil) bassAudio.currentTime = 0 bassAudio.volume = 1.0 bassAudio.delegate = self } func