就像今天一样Friday
,这是6
根据NSCalendar
.我可以通过使用以下内容得到这个
Calendar.current.component(.weekday, from: Date())
Run Code Online (Sandbox Code Playgroud)
我怎么得到Saturday
上周的工作日组件,应该是7
哪个?
如果我这样做 Calendar.current.component(.weekday, from: Date()) - 6
.我得到0
哪个不是有效的组件.
我有一种方法,我有兴趣看到它的功能并深入挖掘; 所以我放了一个断点,然后我介入了这个方法.这个方法沿途执行foreach循环,这个foeach会多次迭代.我对看到foreach循环中的迭代不感兴趣.在Visual Studio中有没有办法我可以走出这个循环并继续调试.
我是 Windows 应用程序开发新手。我正在尝试使用 x64 平台在本地计算机上执行解决方案。但每当我执行 Button_Click 事件时,我都会收到此异常
#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException += (sender, e) =>
{
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
};
#endif
Run Code Online (Sandbox Code Playgroud)
在 App.gics 文件中。
当调试器点击下面的变量“图标”时,我收到此异常
private async void Button_Click(object sender, RoutedEventArgs e)
{
RootObject myWeather =
await OpenWeatherMapProxy.GetWeather(20.0,30.0);
string icon = String.Format("ms-appx:///Assets/Weather/{0}.png", myWeather.weather[0].icon);
ResultImage.Source = new BitmapImage(new Uri(icon, UriKind.Absolute));
ResultTextBlock.Text = myWeather.name + " - " + ((int)myWeather.main.temp).ToString() + " - " + myWeather.weather[0].description;
}
Run Code Online (Sandbox Code Playgroud)
如果有人可以解释如何消除此异常以及 App.gics 文件是什么,那将会很有帮助。
我一直在用它来改变方向
if (UIDevice.current.orientation == UIDeviceOrientation.portrait)
Run Code Online (Sandbox Code Playgroud)
如何用UIInterfaceOrientation.portrait
以上语法替换它。这是因为UIDeviceOreientation
has faceup
和facedown
对我没有用。
我得到true
以下代码的结果
var elements1:[Int] = [10, 20, 30, 40, 50]
if elements1.contains (50) {
print("true")
}
Run Code Online (Sandbox Code Playgroud)
我有问题找出if condition
下面的内容应该是什么,以获得结果,就像true
它elements2
有50.
var elements2:[[Int]] = [[10], [20, 30], [40, 50]]
Run Code Online (Sandbox Code Playgroud) 然后我尝试在轻按单元格时调用操作表,这就是我所做的
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let alertController = UIAlertController(title: "Action Sheet", message: "What do you like to do", preferredStyle: .alert)
let okButton = UIAlertAction(title: "Done", style: .default, handler: { (action) -> Void in
print("Ok button tapped")
})
let deleteButton = UIAlertAction(title: "Skip", style: .destructive, handler: { (action) -> Void in
print("Delete button tapped")
})
alertController.addAction(okButton)
}
Run Code Online (Sandbox Code Playgroud)
当我点击单元格时,警报控制器未显示。我想念什么?
由于ZoneOptions
已弃用,我将optionsByRecordZoneID
变量更改ZoneConfiguration
为如下
var optionsByRecordZoneID = [CKRecordZone.ID: CKFetchRecordZoneChangesOperation.ZoneConfiguration]()
for zoneID in zoneIDs {
let options = CKFetchRecordZoneChangesOperation.ZoneConfiguration()
options.previousServerChangeToken = settings.getChangeToken(forKey: databaseTokenKey)
optionsByRecordZoneID[zoneID] = options
}
Run Code Online (Sandbox Code Playgroud)
现在,对于这行optionsByRecordZoneID
变量,我收到以下错误,
let fetchRecordZoneChangesOperation = CKFetchRecordZoneChangesOperation(recordZoneIDs: zoneIDs, optionsByRecordZoneID: optionsByRecordZoneID)
Run Code Online (Sandbox Code Playgroud)
无法将类型“[CKRecordZone.ID:CKFetchRecordZoneChangesOperation.ZoneConfiguration]”的值转换为预期的参数类型“[CKRecordZone.ID:CKFetchRecordZoneChangesOperation.ZoneOptions]?”
任何有关摆脱它的帮助将不胜感激。
我想知道closure
在函数中是否有使用a 的方法updateView()
,因此该代码not repeated
用于phone
和pad
在下面的代码中。这里封闭应有parameters
的width
和height
@IBInspectable var leftImage: UIImage? {
didSet {
updateView()
}
}
func updateView() {
if let image = leftImage
{
leftViewMode = UITextField.ViewMode.always
if (UIDevice.current.userInterfaceIdiom == .phone)
{
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 20, height: 20))
imageView.contentMode = .scaleAspectFit
imageView.image = image
imageView.tintColor = color
leftView = imageView
}
if (UIDevice.current.userInterfaceIdiom == .pad)
{
let imageView = UIImageView(frame: CGRect(x: …
Run Code Online (Sandbox Code Playgroud)