对成员'下标'的模糊引用在Swift 3中

时间:2016-10-04 06:28:00

标签: ios dictionary swift3 xcode8

我有一个用Swift 1.5构建的项目。当我将代码转换为swift 3.0时,它开始向我显示每个错误,如果'以下代码中的陈述:

 NetworkCredential cred = new NetworkCredential("[account name]", "[person access token]");
             TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("https://[xxx].visualstudio.com"), cred);
            tpc.EnsureAuthenticated();
            VersionControlServer versionControl = tpc.GetService<VersionControlServer>();
Workspace workspace = versionControl.CreateWorkspace("TestWorkspace", versionControl.AuthorizedUser);
try
            {
                String localDir = @"c:\temp\BasicSccExample";
                //Console.WriteLine("\r\n--- Create a mapping: {0} -> {1}", args[1], localDir); 
                workspace.Map("$/Agile2015/APIFolder", localDir);


                workspace.Get();

                Console.WriteLine("\r\n--- Create a file.");
                topDir = Path.Combine(workspace.Folders[0].LocalItem, "sub");
                Directory.CreateDirectory(topDir);
                String fileName = Path.Combine(topDir, "basic.txt");
                using (StreamWriter sw = new StreamWriter(fileName))
                {
                    sw.WriteLine("revision 1 of basic.txt");
                }

                Console.WriteLine("\r\n--- Now add everything.\r\n");
                workspace.PendAdd(topDir, true);

                Console.WriteLine("\r\n--- Show our pending changes.\r\n");
                PendingChange[] pendingChanges = workspace.GetPendingChanges();
                Console.WriteLine("  Your current pending changes:");
                foreach (PendingChange pendingChange in pendingChanges)
                {
                    Console.WriteLine("    path: " + pendingChange.LocalItem +
                                      ", change: " + PendingChange.GetLocalizedStringForChangeType(pendingChange.ChangeType));
                }

                Console.WriteLine("\r\n--- Checkin the items we added.\r\n");
                int changesetNumber = workspace.CheckIn(pendingChanges, "Sample changes");
                }

错误是

  

对成员下标的不明确引用

我尝试了 StackOverflow 上找到的解决方案,但没有运气。请指导。

1 个答案:

答案 0 :(得分:20)

datetimeuserInfo更改为[NSObject : AnyObject]。这假设您的所有[String : AnyObject]值均为ConnectionMessage.xxxKey

您还需要确保传递到String参数的字典实际上是一个类型为userInfo的字典。