我有一个正则表达式,我试图匹配以下类型的数据,每个标记由未知数量的空格分隔.
更新:"文字"几乎可以是任何字符,这就是我.*最初的原因.重要的是,它还可以包括空格.
我想将"Text","01"和"03"作为单独的组捕获,除"Text"之外的所有组都是可选的.到目前为止我能做的最好的是:
\s*(.*)\s+(\d+)\s*(?:\s*\(?\s*(?:of|-)\s*(\d+)\s*\)?\s*)
Run Code Online (Sandbox Code Playgroud)
这匹配#3-#5,并将它们放在适当的捕获组中.但是,我无法弄清楚,为什么当我?在结尾处添加一个额外的部分以使表达式成为01可选项后,我的捕获组会变得非常时髦.
\s*(.*)\s+(\d+)\s*(?:\s*\(?\s*(?:of|-)\s*(\d+)\s*\)?\s*)?
Run Code Online (Sandbox Code Playgroud)
上面的RegEx匹配#2-#5,但捕获组仅对#2和#5正确.
这似乎是一个简单的正则表达式,所以我不知道为什么我遇到这么多麻烦.
这是一个在线RegEx评估员的链接,我用来帮助我调试这个:http://regexr.com?2tb64 .该链接已经有第一个RegEx和填写的测试数据.
我在单元测试期间在Core Data线程上抛出异常,并显示以下消息:
CoreData:错误:严重的应用程序错误.在Core Data更改处理期间捕获到异常.这通常是NSManagedObjectContextObjectsDidChangeNotification的观察者中的错误. - [__ NSCFSet addObject:]:尝试使用userInfo插入nil(null)
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFSet addObject:]: attempt to insert nil'
*** First throw call stack:
(
0 CoreFoundation 0x00683a14 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x02334e02 objc_exception_throw + 50
2 CoreFoundation 0x0068393d +[NSException raise:format:] + 141
3 CoreFoundation 0x005595b9 -[__NSCFSet addObject:] + 185
4 CoreData 0x001d47c0 -[NSManagedObjectContext(_NSInternalChangeProcessing) _processPendingInsertions:withDeletions:withUpdates:] + 560
5 CoreData 0x001cee8a -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 2410
6 CoreData 0x001ce506 -[NSManagedObjectContext processPendingChanges] + 54
7 CoreData 0x001f359b developerSubmittedBlockToNSManagedObjectContextPerform …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用AppleScript确定在iTunes中选择的曲目路径.它似乎不是track班级的财产.谁能告诉我如何获取文件路径?
我的Cocoa应用程序支持将文件拖放到Dock图标上,但我想要根据是否按下修改键(命令,选项等)来执行不同的行为.
我尝试检查modifierFlagsfor currentEvent,但无论是否按下修饰符,它们都是相同的(我正在使用Option键进行测试).
码:
// Code is inside my AppDelegate
- (void)application:(NSApplication *)theApplication openFiles:(NSArray *)files {
BOOL optDown = (([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask)
== NSAlternateKeyMask);
NSLog(@"flags: %u, down? %@", [[NSApp currentEvent] modifierFlags],
optDown ? @"YES" : @"NO");
}
Run Code Online (Sandbox Code Playgroud)
输出(使用Option键关闭文件,然后不丢弃):
flags: 1088, down? NO
flags: 1088, down? NO
Run Code Online (Sandbox Code Playgroud)
预期
flags: <not sure>, down? YES
flags: <different>, down? NO
Run Code Online (Sandbox Code Playgroud) 我正在对 Mac 应用程序进行沙箱处理,并使用OS X 10.7.3 的安全范围书签功能来保留对应用程序沙箱之外的文件的引用。我的所有代码似乎都能正常运行,但最终我在应用程序的输出中重复了数百次以下消息(对于相对简短的操作)。
scoped bookmarks agent connection interrupted
Run Code Online (Sandbox Code Playgroud)
这是一个问题吗?这让我觉得我做错了什么,但我不确定那可能是什么。
对于我正在处理的应用程序,我正在使用CGEventPost发布一些关键事件,我注意到它已停止使用沙盒启用,即使我打开了"启用辅助设备访问"系统首选项.
是否有权允许使用CGEventPost?或者,是否有其他方式可以将提交到Mac App Store的应用发布到关键事件?
当我在Windows中在视网膜MacBook Pro上的VM中运行我的WinForm应用程序时,表单的大小在运行时缩小,而按钮同时向外移动.这可能导致底部边缘的按钮滑到窗口边缘下方,看不见.由于它们是底部锚定的,因此它们完全无法访问.从Windows原生桌面运行时,该应用程序通常表现良好.
只有表单上的字体或DPI AutoScaleMode设置才会出现这种情况.使用Inherit或None,表单及其内容很大,但与我设计它们的方式成正比.
我用一个来自模板的新模板WinForm应用程序重现了这一点,除了调整表单大小,只需按一下按钮就可以了.如何在不相对于彼此改变尺寸的情况下扩展应用程序?
这是InitializeComponent()方法designer.cs:
private void InitializeComponent()
{
this.sendButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// sendButton
//
this.sendButton.Location = new System.Drawing.Point(60, 856);
this.sendButton.Margin = new System.Windows.Forms.Padding(4);
this.sendButton.MinimumSize = new System.Drawing.Size(200, 60);
this.sendButton.Name = "sendButton";
this.sendButton.Size = new System.Drawing.Size(200, 62);
this.sendButton.TabIndex = 1004;
this.sendButton.Text = "Send";
this.sendButton.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(282, 981);
this.Controls.Add(this.sendButton); …Run Code Online (Sandbox Code Playgroud) 我正在我的应用程序中构建一个半透明的浮动HUD窗口,它看起来像Quick Look HUD窗口,特别是使用Enter/Exit全屏图像.Cocoa提供NSEnterFullScreenTemplate(和NSExitFullScreenTemplate)模板,用于此目的,并在带边框按钮上正常工作.
一旦我移除边框并将按钮放在深色背景上,它就会保持深灰色,并且很难看到.我想把它变成白色,就像在Quick Look中一样.有没有内置的方法来做到这一点,或者我是否必须自己使用缩放和着色图像?
我正在使用Xcode的OCUnit来编写单元测试,我的测试调用了一个执行动画的方法.我希望测试方法仅在动画完成后继续.
执行动画的方法没有动画委托,我认为它不应该有.
如何在不设置动画委托的情况下等待动画以测试方法结束?
我一直在摸索,试图弄清楚如何使用Code Player的CSS3 Squircles示例在我的网站上创建一个iOS-7风格的应用程序图标(在Safari浏览器中进行测试)。该示例使用伪标记来裁剪背景颜色,而我需要在周围裁剪<img>。如果您不熟悉,则鼠形就像一个圆角的矩形,但其侧面圆角超出了圆角半径,如下所示:
![]()
.icons img {
width: 100px;
height: 100px;
border-radius: 24%;
}
.icons a {
text-decoration: none;
display: inline-block;
position: relative;
}
/*Now we will create fish-eye shapes using pseudo elements and clip them to add a curve to the sides of the icons*/
.icons a:before, .icons a:after {
content: '';
position: absolute; left: 0; top: 0;
width: 100%; height: 100%;
background: inherit;
border-radius: 100%; /*circle*/
/*time to transform the circle …Run Code Online (Sandbox Code Playgroud)