foundation

Is it possible to build Swift code using the Foundation Framework and target linux?

一笑奈何 提交于 2020-01-22 15:15:23
问题 I know it will be released as open source in the end of the year, however I would like to know, if I create a framework that uses the Foundation framework, will it still be possible to build for Linux? On the announcement it was said that they would be releasing Swift and a compiler for linux. Will builds of the open source version be limited to the standard Swift library? I would really like to create a Web Service in Swift to run in Linux, but I need the Foundation Framework (I don't need

Parsing arbitrary format JSON date with Swift Decodable

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-17 00:27:47
问题 I am attempting to format a date in a JSON document into the format "mm-dd-yyyy". I have the following data: {"data":[{ "id": 123, "url": "https://www.google.com", "title": "The Google link", "created_at": "2017-08-29T04:00:00.000Z",//date to format "sent": true, "alternative": "https://google.com", "things": [], "description": [ "search", "lookup" ], "company": "Alphabet" }]} This is my struct: struct Sitedata: Decodable{ let data: [site] } struct site: Decodable { let id: Int let url:

Where are constant NSStrings allocated?

佐手、 提交于 2020-01-15 09:34:36
问题 I understand that constant CStrings are allocated statically, rather than on the heap. I also noticed that constant NSStrings have an infinite retain count. Does it hold true that constant NSStrings are also allocated statically, rather than on the heap? 回答1: Constant NSStrings are of class NSConstantString , and thus act like atoms in lisp; they hang around. -> NSConstantStrings are allocated statically. That is, if you use @"cow" in two separate places in your code, they will be referencing

“unrecognized selector sent to class” when calling category method from a library

那年仲夏 提交于 2020-01-12 03:32:06
问题 Problem This question may seem a bit long, but I try to give as much information as possible, since I am really staggered by this. I am currently working an a library which should automate XML document parsing. But I am running into a problem now testing the library for the first time. I have a library class called CSXDocumentLayout which represents the layout of a document. This class contains the private method - (NSError *)readLayoutDocument:(NSString *)fpath called from an init method. /*

Folding/Normalizing Ligatures (e.g. Æ to ae) Using (Core)Foundation

纵饮孤独 提交于 2020-01-10 19:45:09
问题 I am writing a helper that performs a number of transformations on an input string, in order to create a search-friendly representation of that string. Think of the following scenario: Full text search on German or French texts The entries in your datastore contain Müller Großmann Çingletòn Bjørk Æreogramme The search should be fuzzy, in that ull , Üll etc. match Müller Gros , groß etc. match Großmann cin etc. match Çingletòn bjö , bjo etc. match Bjørk aereo etc. match Æreogramme So far, I've

Detect any connected network

孤者浪人 提交于 2020-01-10 09:13:28
问题 How can I detect if any network adapter is connected? I can only find examples on using NSReachability to detect an internet connection, but I want to detect even a non-internet network connection. Getting the IP-adress on eth0 should work? I'm working on Mac only. 回答1: Getting a List of All IP Addresses in Apple's Technical Note TN1145 mentions 3 methods for getting the status of the network interfaces: System Configuration Framework Open Transport API BSD sockets System Configuration

Detect any connected network

风流意气都作罢 提交于 2020-01-10 09:13:10
问题 How can I detect if any network adapter is connected? I can only find examples on using NSReachability to detect an internet connection, but I want to detect even a non-internet network connection. Getting the IP-adress on eth0 should work? I'm working on Mac only. 回答1: Getting a List of All IP Addresses in Apple's Technical Note TN1145 mentions 3 methods for getting the status of the network interfaces: System Configuration Framework Open Transport API BSD sockets System Configuration

Facade在Laravel中的工作机制

房东的猫 提交于 2020-01-07 15:55:20
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 我们知道Facade门面模式是一个中介类,对子系统或者类对象进行封装和代理,为子系统的一组接口提供一个统一的高层接口。它对外暴露子系统的功能,但是不暴露子系统对象,用户要使用子系统的某个功能(方法)时,先调用门店,由于门店代理了子系统,所以委托子系统去处理相应的功能请求,从而达到将用户和子系统解耦的目的,用户只需要和门店打交道,不需要知道所有的子系统及其内部构造。 我们接下来通过在Laravel中最常用的DB-Facade,来看看Facade在Laravel中是如何工作的。 1,代码如下 <?php use Exception; use Illuminate\Support\Facades\DB; Class A { function a() { try { DB::beginTransaction(); //do something DB::commit(); } catch (Exception $e) { DB::rollback(); // handle exception } } } 这里,我们看到use了一个DB的Facades,为什么写了DB两个字母,就会自动use DB的Facade呢?这就涉及到 Laravel的自动加载和依赖注入机制,这里略过。 我们来看看这个类文件的代码: 2, DB

CSS开发中的十大错误用法

空扰寡人 提交于 2020-01-07 01:22:44
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 自从接触前端软件开发以来,我发现开发猿一直在努力征服着CSS。 理由也很充分,开发人员是用逻辑思考的生物。 添加一个DIV元素导致所有代码都不得不往下移一行,而另一个DIV“浮”到左侧,感觉没有任何意义。 你也一定听到过开发人员的抱怨: “我们只需要向左边移动五个像素,但是…天哪!为什么整个都向下移动了一行。到底是哪里错了?!?!?!” 所以,这篇文章就和大家来聊一聊CSS中的十大错误的做法。 1.不要滥用类 在有意义的地方使用ID而不要使用类。这是一个使得浏览器能够更快访问DOM元素的方法。 2.不要把一切都扔进一个CSS文件中 分区CSS使其更易于管理。每一个CSS文件都可以分解成例如header.css、footer.css等逻辑组件。 3.不要害怕开发工具 现在的每个浏览器都有自己的一套开发工具,通常是按F12。这些工具在“调试CSS”时至关重要。 4.不要忘记注释 注释在CSS中非常重要,可用来理解每个样式如何与其他样式关联以及什么颜色方案适用于哪些组件。 5.不要命名选择器为“.red-with-green-dashed-lines”(红绿虚线) 根据页面上的组件命名你的选择器。例如:“header-left”,“content-title”或“content-date”更具描述性。 6.不要滥用

GPL协议中国第一案尘埃落定,相关开源软件应如何风控?

て烟熏妆下的殇ゞ 提交于 2020-01-06 22:05:46
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 导读:2019年11月6日,数字天堂(北京)网络技术有限公司(以下简称 “数字天堂公司”)诉柚子(北京)科技有限公司、柚子(北京)移动技术有限公司(以下简称 “柚子公司”)侵犯计算机软件著作权纠纷一案由北京市高级人民法院做出二审终审判决,认定柚子公司提出的HBuilder软件三个插件属于应遵循《GNU通用公共许可协议》(以下简称“GPL协议”)开放源代码的衍生作品的抗辩理由不成立,APICloud软件复制并修改HBuilder软件中的三个插件的行为构成对数字天堂公司复制权、改编权及信息网络传播权的侵犯,判令柚子公司停止侵权并赔偿71万元。至此,第一个在中国涉及GPL协议的诉讼案件结局已尘埃落地。 本案作为中国第一个关涉GPL协议的诉讼案件,对开源软件许可协议在中国司法程序中的效力认定和中国法院对于GPL协议的条款解读具有重要的参考意义。 本文将对案件中涉及GPL协议的部分展开讨论,并就此提出商业公司使用GPL协议的开源软件时应如何开展风险管控的思考。 一、案情介绍 1.一审案情简介 原告数字天堂公司起诉被告柚子公司侵犯其计算机软件著作权纠纷一案,由北京知识产权法院于2015年4月13日受理,并于2018年4月12日作出判决[1]。