GVKun编程网logo

无法将Google iOS Analytics(分析)强制类型'NSMutableDictionary'的值转换为类型[[NSObject:AnyObject]'

2

在这篇文章中,我们将为您详细介绍无法将GoogleiOSAnalytics的内容,并且讨论关于分析强制类型'NSMutableDictionary'的值转换为类型[[NSObject:AnyObjec

在这篇文章中,我们将为您详细介绍无法将Google iOS Analytics的内容,并且讨论关于分析强制类型'NSMutableDictionary'的值转换为类型[[NSObject:AnyObject]'的相关问题。此外,我们还会涉及一些关于angular – 无法解析AuthenticationService的所有参数:([object Object],?,[object Object])、c# – 无法将MyObject类型的对象强制转换为MyObject类型、delphi – 使用Genericics.Collections.TObjectDictionary的示例、Google Analytics(分析)广告系列网址跟踪未显示在 Google Analytics(分析)仪表板中的知识,以帮助您更全面地了解这个主题。

本文目录一览:

无法将Google iOS Analytics(分析)强制类型'NSMutableDictionary'的值转换为类型[[NSObject:AnyObject]'

无法将Google iOS Analytics(分析)强制类型'NSMutableDictionary'的值转换为类型[[NSObject:AnyObject]'

我想将Google Analytics(分析)iOS添加到我的项目中,但是当我尝试将其代码粘贴到我的应用程序中时,如下面的代码,遇到了一些问题。

var tracker = GAI.sharedInstance().defaultTrackertracker.set(kGAIScreenName, value: "rootPlayView")var builder = GAIDictionaryBuilder.createScreenView()tracker.send(builder.build() as [NSObject : AnyObject])

然后我得到了这样的错误

在此处输入图片说明

我怎样才能解决这个问题?

谢谢!

答案1

小编典典

类型转换

类型转换表

迅捷3

屏幕轨迹

let tracker = GAI.sharedInstance().defaultTrackertracker.set(kGAIScreenName, value: "Home")tracker.send(GAIDictionaryBuilder.createScreenView().build() as [AnyHashable : Any])

目标C

id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];// Set the screen name on the tracker so that it is used in all hits sent from this screen.[tracker set:kGAIScreenName value:@"Home"];[tracker send:[[GAIDictionaryBuilder createScreenView]  build]];

自动屏幕跟踪

迅捷3

override func viewDidAppear(_ animated: Bool) {    super.viewDidAppear(animated)    self!.screenName = "About Screen"}

目标C

- (void)viewDidAppear:(BOOL)animated {    [super viewDidAppear:animated];    self.screenName = @"About Screen";}

事件追踪

迅捷3

let tracker = GAI.sharedInstance().defaultTrackertracker!.send(GAIDictionaryBuilder.createEventWithCategory("ui_action", action: "button_press", label: "menuButton", play: nil).build())

目标C

id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];[tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"ui_action"     // Event category (required)    action:@"button_press"  // Event action (required)    label:@"play"               value:nil] build]];

或使用

weak var tracker = GAI.sharedInstance().defaultTracker// Set screen name on the tracker to be sent with all hits. tracker!.set(kGAIScreenName, value: "Home Screen")// Send a screen view for "Home Screen".// [tracker send:[[GAIDictionaryBuilder createAppView] build]];// Previous V3 SDK versions.tracker!.send(GAIDictionaryBuilder.createScreenView().build())// SDK Version 3.08 and up.// This event will also be sent with &cd=Home%20Screen.tracker!.send(GAIDictionaryBuilder.createEventWithCategory("UX", action: "touch", label: "menuButton", value: nil).build())// Clear the screen name field when we''re done.tracker!.set(kGAIScreenName, value: nil)

有关更多信息,请参阅此

试试这个

var builder = GAIDictionaryBuilder.createScreenView().build() as! [NSObject : AnyObject]tracker.send(builder)

用于屏幕跟踪

let tracker = GAI.sharedInstance().defaultTrackertracker.set(kGAIDescription, value: "rootPlayView")let builder: NSObject = GAIDictionaryBuilder.createScreenView().build()tracker.send(builder as! [NSObject : AnyObject])

用于事件跟踪

let tracker = GAI.sharedInstance().defaultTrackerlet builder: NSObject = GAIDictionaryBuilder.createEventWithCategory(            "xxxx",            action: "buttonclicked",            label: "you pressed xxx button",            value: nil).build()tracker.send(builder as! [NSObject : AnyObject])

angular – 无法解析AuthenticationService的所有参数:([object Object],?,[object Object])

angular – 无法解析AuthenticationService的所有参数:([object Object],?,[object Object])

我遇到了下一个错误,无法理解如何解决它.

Can’t resolve all parameters for AuthenticationService: ([object Object],?,[object Object])

我已经检查了几乎每个主题,并尝试了多种方法来解决它,但仍然无法在第二天击败它.

我试图像这样在appService中注入第一个authService但是得到了同样的错误

@Inject(forwardRef(() => AuthenticationService)) public authService: AuthenticationService

我检查了所有DI和服务内部的导入顺序,在我看来一切都是正确的

如果有人可以帮我处理它,我很感激.

Angular 4.0.0

AuthService

import { Injectable } from '@angular/core';
import {Http,Headers,Response} from '@angular/http';
import 'rxjs/add/operator/toPromise';
import {Observable} from 'rxjs/Rx';

import {AppServices} from "../../app.services";
import {Router} from "@angular/router";

@Injectable()
export class AuthenticationService {
  public token: any;

  constructor(
    private http: Http,private appService: AppServices,private router: Router
  ) {
    this.token = localStorage.getItem('token');
  }

  login(username: string,password: string): Observable<boolean> {
    let headers = new Headers();
    let body = null;
    headers.append("Authorization",("Basic " + btoa(username + ':' + password)));

    return this.http.post(this.appService.api + '/login',body,{headers: headers})
      .map((response: Response) => {
        let token = response.json() && response.json().token;
        if (token) {
          this.token = token;
          localStorage.setItem('Conform_token',token);
          return true;
        } else {
          return false;
        }
      });
  }

  logout(): void {
    this.token = null;
    localStorage.removeItem('Conform_token');
    this.router.navigate(['/login']);
  }
}

应用服务

import {Injectable} from '@angular/core';
import {Headers,Http,RequestOptions} from '@angular/http';
import {Router} from "@angular/router";
import {AuthenticationService} from "./auth/auth.service";

import 'rxjs/add/operator/toPromise';
import {Observable} from 'rxjs/Rx';

@Injectable()

export class AppServices {

  api = '//endpoint/';

  public options: any;
  constructor(
    private http: Http,private router: Router,public authService: AuthenticationService // doesn't work
  //  @Inject(forwardRef(() => AuthenticationService)) public authService: AuthenticationService // doesn't work either
      ) {
        let head = new Headers({
      'Authorization': 'Bearer ' + this.authService.token,"Content-Type": "application/json; charset=utf8"
    });
    this.options = new RequestOptions({headers: head});
  }

  // ====================
  //    data services
  // ====================

  getData(): Promise<any> {
    return this.http
      .get(this.api + "/data",this.options)
      .toPromise()
      .then(response => response.json() as Array<Object>)
      .catch((err)=>{this.handleError(err);})
  }

应用模块

import { browserModule } from '@angular/platform-browser';
import { browserAnimationsModule } from '@angular/platform-browser/animations';

import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import {BaseRequestOptions,HttpModule} from '@angular/http';

import { MaterialModule} from '@angular/material';
import {FlexLayoutModule} from "@angular/flex-layout";
import 'hammerjs';

import { routing,appRoutingProviders }  from './app.routing';
import { AppServices } from './app.services';
import {AuthGuard} from "./auth/auth.guard";
import {AuthenticationService} from "./auth/auth.service";

import {AppComponent} from './app.component';
import {AuthComponent} from './auth/auth.component';
import {NotFoundComponent} from './404/not-found.component';
import { HomeComponent } from './home/home.component';

@NgModule({
  declarations: [
    AppComponent,AuthComponent,NotFoundComponent,HomeComponent
  ],imports: [
    browserModule,browserAnimationsModule,FormsModule,HttpModule,routing,MaterialModule,FlexLayoutModule
  ],providers: [AppServices,AuthGuard,AuthenticationService],bootstrap: [AppComponent]
})
export class AppModule { }

解决方法

AppServices和AuthenticationService之间存在循环依赖关系 – 这与Angular使用的构造函数注入无法实现.

你可以使用

export class AuthenticationService {
  public token: any;
  appService: AppServices;
  constructor(
    private http: Http,// private appService: AppServices,injector:Injector;
    private router: Router
  ) {
    setTimeout(() => this.appService = injector.get(AppServices));
    this.token = localStorage.getItem('token');
  }

另见DI with cyclic dependency with custom HTTP and ConfigService

要避免使用setTimeout,您还可以从AppService的构造函数中设置AuthenticationService.appService(或者相反)

c# – 无法将MyObject类型的对象强制转换为MyObject类型

c# – 无法将MyObject类型的对象强制转换为MyObject类型

我有这种情况,我在C#中使用的Web服务方法返回一个Business对象,当使用以下代码调用webservice方法时,我在reference.cs类中得到异常“无法将ContactInfo类型的对象强制转换为类型ContactInfo”的网络参考

码:

ContactInfo contactInfo = new ContactInfo();
Contact contact = new Contact();

contactInfo = contact.Load(this.ContactID.Value);

任何帮助将非常感激.

解决方法

这是因为其中一个ContactInfo对象是Web服务代理,并且位于不同的命名空间中.

这是asmx风格的Web服务的一个已知问题.在过去,我已经实现了自动浅拷贝来解决它(here’s how,虽然如果我再次这样做,我可能会看一下AutoMapper).

例如,如果您有一个包含以下类的程序集:

MyProject.ContactInfo

并从web方法返回它的实例:

public class DoSomethingService : System.Web.Services.WebService
{
    public MyProject.ContactInfo GetContactInfo(int id)
    {
        // Code here...
    }
}

然后,当您将Web引用添加到客户端项目时,实际上是这样的:

MyClientProject.DoSomethingService.ContactInfo

这意味着如果在您的客户端应用程序中调用Web服务来获取ContactInfo,则会出现以下情况:

namespace MyClientProject
{
    public class MyClientClass
    {
        public void AskWebServiceForContactInfo()
        {
            using (var service = new DoSomethingService())
            {
                MyClientProject.DoSomethingService.ContactInfo contactInfo = service.GetContactInfo(1);

                // ERROR: You can't cast this:
                MyProject.ContactInfo localContactInfo = contactInfo;
            }
        }
    }
}

它是在我使用我的Shallowcopy类的最后一行:

namespace MyClientProject
{
    public class MyClientClass
    {
        public void AskWebServiceForContactInfo()
        {
            using (var service = new DoSomethingService())
            {
                MyClientProject.DoSomethingService.ContactInfo contactInfo = service.GetContactInfo(1);

                // We actually get a new object here,of the correct namespace
                MyProject.ContactInfo localContactInfo = Shallowcopy.copy<MyClientProject.DoSomethingService.ContactInfo,MyProject.ContactInfo>(contactInfo);
            }
        }
    }
}

注意这只能起作用,因为代理类和“真实”类具有完全相同的属性(一个是由Visual Studio生成的).

delphi – 使用Genericics.Collections.TObjectDictionary的示例

delphi – 使用Genericics.Collections.TObjectDictionary的示例

Delphi XE2在线帮助(以及Embarcadero DocWiki)在TObjectDictionary的文档中非常薄(或者我太愚蠢地找不到).

据我所知,它可以用于存储可以通过字符串键访问的对象实例(基本上是使用排序的TStringList但是类型安全的).但是我如何实际申报和使用它是一个失败.

任何指针?

解决方法

TObjectDictionaryTDictionary之间的主要区别在于提供了一种机制来指定添加到集合(字典)中的键和/或值的所有权.因此,您不必担心释放这些对象.

检查这个基本样本

{$APPTYPE CONSOLE}    
{$R *.res}
uses
  Generics.Collections,Classes,System.SysUtils;


Var
  MyDict  : TObjectDictionary<String,TStringList>;
  Sl      : TStringList;
begin
  ReportMemoryLeaksOnShutdown:=True;
  try
   //here i'm  creating a TObjectDictionary with the Ownership of the Values 
   //because in this case the values are TStringList
   MyDict := TObjectDictionary<String,TStringList>.Create([doOwnsValues]);
   try
     //create an instance of the object to add
     Sl:=TStringList.Create;
     //fill some foo data
     Sl.Add('Foo 1');
     Sl.Add('Foo 2');
     Sl.Add('Foo 3');
     //Add to dictionary
     MyDict.Add('1',Sl);

     //add another stringlist on the fly 
     MyDict.Add('2',TStringList.Create);
     //get an instance  to the created TStringList
     //and fill some data
     MyDict.Items['2'].Add('Line 1');
     MyDict.Items['2'].Add('Line 2');
     MyDict.Items['2'].Add('Line 3');


     //finally show the stored data
     Writeln(MyDict.Items['1'].Text);
     Writeln(MyDict.Items['2'].Text);        
   finally
     //only must free the dictionary and don't need to worry for free the TStringList  assignated to the dictionary
     MyDict.Free;
   end;
  except
    on E: Exception do
      Writeln(E.ClassName,': ',E.Message);
  end;
  Readln;
end.

检查此链接Generics Collections TDictionary (Delphi)有关如何使用TDictionary的完整示例(请记住与TObjectDictionary的唯一区别是构造函数中指定的键和/或值的所有权,因此相同的概念适用于两者)

Google Analytics(分析)广告系列网址跟踪未显示在 Google Analytics(分析)仪表板中

Google Analytics(分析)广告系列网址跟踪未显示在 Google Analytics(分析)仪表板中

如何解决Google Analytics(分析)广告系列网址跟踪未显示在 Google Analytics(分析)仪表板中?

在网上看过,似乎不是最近的例子。创建了营销活动 URL 并添加到测试简报版本中。

https://frasercoutts.com?utm_source=Newsletter+&utm_medium=Email&utm_campaign=Fintech_Newsletter_2021&utm_id=FTN21

简报链接将我带到我的网站,并实时显示流量,但不是简报广告系列的特定点击。在 Google Analytics(分析)中没有可见的广告系列部分或标签。

是否只有 24 到 28 小时的延迟才会显示在 Google Analytics(分析)中,还是广告系列网址不正确?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

今天关于无法将Google iOS Analytics分析强制类型'NSMutableDictionary'的值转换为类型[[NSObject:AnyObject]'的介绍到此结束,谢谢您的阅读,有关angular – 无法解析AuthenticationService的所有参数:([object Object],?,[object Object])、c# – 无法将MyObject类型的对象强制转换为MyObject类型、delphi – 使用Genericics.Collections.TObjectDictionary的示例、Google Analytics(分析)广告系列网址跟踪未显示在 Google Analytics(分析)仪表板中等更多相关知识的信息可以在本站进行查询。

本文标签: