草庐IT

delegating-constructor

全部标签

ios - iOS 中未调用自定义委托(delegate)方法

我在从我的iOS应用程序中的Web服务获取数据时遇到问题。我有一个名为LoginService的NSObject类。当用户单击“登录”时,从ViewController调用LoginService的loginWithUsername方法。在我的LoginService中,我创建了一个名为LoginServiceDelegate的委托(delegate)。以下是LoginService.h中的代码://Creatingcustomdelegate@protocolLoginServiceProtocol-(void)loginResult:(NSDictionary*)loginData

ios - Objective-C,委托(delegate)为适配器模式 : who is the adaptee?

我不止一次读到Cocoa中使用的委托(delegate)模式是Adaptern模式(http://en.wikipedia.org/wiki/Adapter_pattern)的实现。它们有着相同的意图,那就是:让两个接口(interface)不兼容的对象一起工作。委托(delegate)对象是适配器,因为它采用了客户端需要的协议(protocol),需要协议(protocol)并且对委托(delegate)有弱引用的类是客户端(因此,这将是Cocoa框架的一个类)。我的问题是:谁是Adaptee?delegate模式不会自己包裹任何对象,据我所见,需要适配的对象是谁?

iPhone - 委托(delegate)或通知?

您有一个类必须向其父类发送消息。您的应用程序的任何其他成员都不使用此类。您将消息作为NSNotification发送,或者在该类上创建委托(delegate)协议(protocol)并在父类中实现委托(delegate)方法,以便发送消息?什么是最好的方法,为什么?一种方法比另一种方法有什么优势吗?谢谢 最佳答案 当您有多个对通知感兴趣的观察者或对象时,通知很有用。They'realsousefulforKeyValueObserving.委托(delegate)对于从一个对象向指定为委托(delegate)目标的另一个对象发送消息

ios - 单例和委托(delegate)

我阅读了足够多的关于单例和委托(delegate)的信息。所以,我想我明白了什么是单例。关于授权,我仍然感到困惑。我理解委托(delegate)的概念,但我需要创建我的协议(protocol)来理解委托(delegate)。好的,我创建了单例来处理我来自CoreData的实体。也许我错了,它不是单例,请告诉我。我的单例是FetchData。获取数据.h#import@interfaceFetchData:NSObject+(FetchData*)fetchData;-(NSArray*)fetchLogin:(NSString*)name;-(BOOL)newGroup:(NSStri

ios - 在ios中实现CLLocationManager的didUpdateLocations委托(delegate)方法

我已经在DashboardController.m中实现了-(void)localnotification。现在我想访问localnotification并在settingsController中实现didUpdateLocations委托(delegate)方法.m类。到目前为止,我的方法是:DashBoardViewController.h#import@classAppDelegate;@interfaceDashBoardViewController:UIViewController{AppDelegate*appDel;}@property(nonatomic,strong)

iphone - 当我们从表中重新加载数据时,UITable View 数据源和委托(delegate)的顺序是什么?

你好我是iOS初学者在我的一项事件中我想重新加载表格数据......然后我应用了这段代码......-(void)buttonpress{for(inti=0;itable_AdviseTestDetailscellForRowAtIndexPath:indexPath1];NSLog(@"cell%@",mycel);UILabel*mybutton=(UILabel*)[mycelviewWithTag:100+j];//mybutton.selected=YES;NSLog(@"label%@",mybutton.text);r=r+[mybutton.textfloatValu

iphone - @property (nonatomic, assign) id <IconDownloaderDelegate> 委托(delegate);

谁能解释一下这行是什么意思?我曾经看到(nonatomic,retain)这是我第一次看到“assign”关键字:@property(nonatomic,assign)iddelegate;谢谢你的帮助,史蒂芬 最佳答案 基于Peter的回答:创建属性时,可以使用@synthesize指令自动创建getter和setter方法。编译器不仅创建了两个方法-(id)delegate;-(void)setDelegate:(id)newDelegate;但也为此添加了额外的代码,以防止多个线程同时更改该属性(本质上是一个锁)。nonato

objective-c - Objective-C : Delegate method not getting called

我是iOSDev的新手,我正在学习2010年秋季的斯坦福CS193P类(class)。我正在做作业3,我正在将我的委托(delegate)设置为我的View,并通过使用调试器我注意到调用我的委托(delegate)方法不会发生,我不明白会发生什么。我的代码如下:GraphViewController.h:@interfaceGraphViewController:UIViewController{GraphView*graphView;floatscale;}@property(retain)IBOutletGraphView*graphView;@propertyfloatscale

ios - 为自定义协议(protocol)设置委托(delegate)时收到警告

我向我的一个类添加了一个自定义协议(protocol),当我尝试在prepareForSegue:方法期间设置委托(delegate)时,我收到编译器警告。我得到的警告是……Sending'MyCustomViewControllerClass*const__strong'toparameterofincompatibletype'id'项目构建并运行,除警告外一切正常。如果我添加对于我的自定义类(class),警告消失了。我错过了什么或者这是Xcode(6beta)中的错误吗?该代码是用于设置协议(protocol)/委托(delegate)的标准代码,但无论如何我都会发布它....

constructor - Kotlin 在声明之前初始化变量?

这是我的测试代码:classTest{init{a=1}constructor(){a=2}privatevara:Intinit{a=3}}如果我删除辅助构造函数:classTest{init{a=1//Error:Variablecannotbeinitializedbeforedeclaration}//constructor(){//a=2//}privatevara:Intinit{a=3}}我知道Duringaninstanceinitialization,theinitializerblocksareexecutedinthesameorderastheyappearin