protocols

How do I know which object is asking the delegate for information?

瘦欲@ 提交于 2019-12-12 02:28:58
问题 In my design, choosers tell an app controller how many items, and of which color, the user would like to see in each of two Views. I have a single NSView object description (myView.h, myView.m) which the controller instantiates twice. When the user adjusts a chooser to change, say, the number of items to be drawn in viewOne, the App Controller updates its local variable for this qty, and tells viewOne to redraw itself. As part of redrawing itself, viewOne needs to ask the delegate (App

No type or protocol named

你。 提交于 2019-12-12 02:26:09
问题 After searching of an the answer to this I found many related questions but after implementing them I am still unable to get rid of this error. I've a class which is of AFHTTPRequestOperationManager type. In this class .h file right after the Import statements end I have written @protocol apiClientDelegate; and in the @interface there is a @property (weak) id<apiClientDelegate>delegate; and after it @end I've written: @protocol apiClientDelegate <NSObject> @required -(void)finalImageURLs:

Swift declare that AnyClass object implements protocol

时间秒杀一切 提交于 2019-12-12 02:06:44
问题 I am currently writing a framework for creating plugins for my OS X application. These plugins are loaded as NSBundle s, and the bundles' principalClass es are used to run the plugin code. However, I can't figure out how to declare that the principalClass object conforms to my protocol. let bundles = CFBundleCreateBundlesFromDirectory(kCFAllocatorDefault, NSURL(fileURLWithPath: bundleDirectory), "bundle") as NSArray for bundle in bundles { let bundleClass = bundle.principalClass!! if

Making a protocol's property KVC compliant

落爺英雄遲暮 提交于 2019-12-12 01:55:10
问题 I'm using Xcode 6.1.1 and the iOS SDK 8.1 I have a class that is derived from NSObject , but its property is defined in a protocol (it is called phoneNumber , which I don't believe to be a problematic name). I'm getting the error message this class is not key value coding-compliant for the key phoneNumber. so I implemented the valueForKey: and setValue:ForKey: methods on my own and it fixed it. Is there a better way of doing making it KVC compliant? 回答1: Auto property synthesis will not

Swift: Delegation protocol not setting UILabel properly

给你一囗甜甜゛ 提交于 2019-12-12 01:40:12
问题 I have the following Protocol : protocol SoundEventDelegate{ func eventStarted(text:String) } which I call in this class: class SoundEvent { var text:String var duration:Double init(text: String, duration: Double){ self.text = text self.duration = duration } var delegate : SoundEventDelegate? func startEvent(){ delegate?.eventStarted(self.text) } func getDuration() -> Double{ return self.duration //TODO is this common practice? } } Which I have my ViewController conform to: class

Call a function of an another class (protocol)

情到浓时终转凉″ 提交于 2019-12-11 23:05:08
问题 I have a Slide out navigation panel (menu) and an another "menu" on my first page. Slide out Menu: Index Page 1 Page 2 Page 3 Page 4 On Index: Page 1 Page 2 Page 3 Page 4 So the user have access to the pages from the Index or by Sliding (or tap on Icon Menu) to have the menu. But I have an error: I go to page 1 from the Index, I tap on the Icon Menu to slide out the Menu I tap on index, I go to page 1 again from the Index, and here if I tap again on the Icon Menu, I get error: SIGBRT

Iterable Array of Enums

安稳与你 提交于 2019-12-11 17:52:13
问题 I am trying to initialize a deck of cards. I have card attributes in my card struct. My approach is to try and create an array of "enum states", then iterate through those to initialize each card. I am having trouble doing so. Game Class import Foundation struct Set{ var cards = [Card]() init(){ let properties : [Any] = [cardShape.self, cardColor.self, cardNumber.self, cardShading.self] for prop in properties{ // Not really sure how to iterate through this array... // Ideally it would be

Core Location Best Placement and User Interruption

梦想与她 提交于 2019-12-11 16:57:28
问题 My application uses Core Location in three different views. It's working perfectly. In my first view, I subclass the CLLocationManager and use protocol methods for location updates to my calling class. Before I install the framework and code in my other classes, I was wondering: Is the protocol method the best way? What happens to the Core Location execution if the user exits the view or quits the app while it's trying to get a location fix? Is the location task terminated with the GPS system

Using KoolPlot On Linux (Linux Mint 10)? Or Is it for MingW Only..?

笑着哭i 提交于 2019-12-11 16:45:23
问题 I need to plot real time statistics for a data transfer being done using udp (socket) protocol for my project. Stats like the average speed, total throughput, etc. My code is in C++. As I googled first, I liked the "koolplot" implementation for plotting 2-D graphs/plots a lot. But when I compiled it/tried to take up the example koolplot app. I simply wasn't able to resolve the missing "graphics.h". My best guess is that it's not there in linux. Is it? Thats for BGI graphics under borland. Eh?

Property does not conform to protocol

≡放荡痞女 提交于 2019-12-11 16:44:55
问题 I am having problems getting my property to conform to my self made protocol my property is declared like this: @property(assign)id <MainViewDatasource> datasource And I run this code to test if it conforms to the protocol: if ([datasource conformsToProtocol:@protocol(MainViewDatasource)]) NSLog(@"datasource conforms to MainViewDatasource"); if(datasource == nil) NSLog(@"datasource is nil"); And in the Console it says that datasource is nil. How do I fix this? 回答1: If you don't set your