所以,我们谈论的是angular2,我知道它仍处于alpha状态.我创建了一个我将在另一个服务中使用的基本服务.然后将后者用于组件中.
基本服务看起来像这样
import {Injectable, Observable} from 'angular2/core';
import {Http} from 'angular2/http';
import {RequestOptionsArgs, Connection, ConnectionBackend} from 'angular2/http';
import {BaseRequestOptions, RequestOptions} from 'angular2/http';
import {RequestMethods} from 'angular2/http';
import {Response} from 'angular2/http';
import {Request} from 'angular2/http';
import {makeTypeError} from 'angular2/src/facade/exceptions';
@Injectable()
export class MyOAuth extends Http {
constructor(backend: ConnectionBackend, defaultOptions: RequestOptions) {
super(backend, defaultOptions);
}
/**
* Performs any type of http request. First argument is required, and can either be a url or
* a {@link Request} instance. If the first …Run Code Online (Sandbox Code Playgroud) 当我尝试在我的对象pageModel上调用此函数时,我在我的应用程序中遇到了这种奇怪的崩溃
[pageModel pageTitle] isEqualToString:@"some text"];
Run Code Online (Sandbox Code Playgroud)
这是调试器转储
-[__NSArrayM isEqualToString:]: unrecognized selector sent to instance 0x661de40
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM isEqualToString:]: unrecognized selector sent to instance 0x661de40'
Run Code Online (Sandbox Code Playgroud)
并且搞乱调试器我发现了一些非常奇怪的行为
(gdb) po pageModel
<PXPage: 0x6622e20>
(gdb) po [pageModel pageTitle]
<__NSArrayM 0x661de40>(...
(gdb) po pageModel.pageTitle
<__NSArrayM 0x661de40>(...
Run Code Online (Sandbox Code Playgroud)
它认为这是一个MutableArray,但事实并非如此.它应该是一个NSString ...而另一些时间它是UIImage,其他时间是其他东西等等.有谁知道这里发生了什么?
谢谢