我在ARC
引用计数方面有点混乱你可以告诉我下面的波纹管代码的参考数量.
var vc1 = UIViewController()
var vc2 = vc1
var vc3 = vc2
weak var vc4 = vc3
Run Code Online (Sandbox Code Playgroud)
问题是:
我们如何在UIAlertcontroller中将归属文本设置为消息.我的尝试代码如下,但它会崩溃的应用程序.
// create Attributed text
let myAttribute = [NSForegroundColorAttributeName: UIColor(red:122.0/255, green:125.0/255, blue:131.0/255, alpha:1.0),NSFontAttributeName: Constant.flinntRegularFont(15)]
let myAttribute2 = [NSForegroundColorAttributeName: UIColor.blackColor(),NSFontAttributeName: Constant.flinntMediumFont(15)]
let myString = NSMutableAttributedString(string: "You have been unsubscribed from ", attributes: myAttribute)
let myString2 = NSMutableAttributedString(string: self.course.course_name, attributes: myAttribute2)
let myString3 = NSMutableAttributedString(string: "\n\nYour refund will be initiated within one week.", attributes: myAttribute)
let myString4 = NSMutableAttributedString(string: "\n\nFor any help call us on", attributes: myAttribute)
let myString5 = NSMutableAttributedString(string: " 079-4014 9800", attributes: myAttribute2)
let myString6 = NSMutableAttributedString(string: " between …
Run Code Online (Sandbox Code Playgroud) 我有2个活动.
ActivityA
通过Content Provider访问数据库,然后启动ActivityB
.
ActivityB
直接访问数据库.
我发现ActivityB
更新数据库后,ActivityA
通过CP查询数据库,结果不会更新.
但数据库实际上已更新!
如何同步这两种方法?
PS:ActivityA
并且ActivityB
在不同的应用程序中.
我正在尝试通过instagram意图共享文件,但我意识到在API 24 ++上,我不能在未经许可的情况下仅将URI共享给其他应用。
按照此https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat/zh-CN教程,我已经设置了提供程序并提供了这样的路径:
表现
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="myapplication.file_provider"
android:exported="false"
android:grantUriPermissions="true"
tools:node="replace">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
Run Code Online (Sandbox Code Playgroud)
注意:有`tools:node = replace“来覆盖库RxPaparazzo中的提供者。
provider_paths.xml
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="my_images" path="files/"/>
</paths>
Run Code Online (Sandbox Code Playgroud)
保存位图并获取uri的代码
public static Uri savePicture(Context context, Bitmap bitmap) {
int cropHeight;
if (bitmap.getHeight() > bitmap.getWidth()) cropHeight = bitmap.getWidth();
else cropHeight = bitmap.getHeight();
bitmap = ThumbnailUtils.extractThumbnail(bitmap, cropHeight, cropHeight, ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
File mediaStorageDir = new File(
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
context.getString(R.string.app_name)
);
if (!mediaStorageDir.exists()) {
if (!mediaStorageDir.mkdirs()) {
return null;
}
}
String timeStamp = new …
Run Code Online (Sandbox Code Playgroud) 这是我的目标 FTContent
class FTContent: NSManagedObject {
@NSManaged var content_id: String // Primary key
@NSManaged var title: String
}
Run Code Online (Sandbox Code Playgroud)
在我的课堂上,我有一个保持FTContent
元素的Set
var mySet: Set<FTContent>
Run Code Online (Sandbox Code Playgroud)
一些操作后mySet
包含5个元素FTContent
现在我想要元素(FTContent
) mySet
如何从集合中获取元素?
当尝试获取当时给定范围的子数组时出现此错误。
Cannot subscript a value of type '[Info]' with an index of type 'CountableRange<Int>' .
Run Code Online (Sandbox Code Playgroud)
我的代码是
信息模态
class Info : NSObject {
var type : Type = .Unknown
var data = ""
init() {
super.init()
}
}
Run Code Online (Sandbox Code Playgroud)
数组声明
var currentData : [Info] = []
Run Code Online (Sandbox Code Playgroud)
在尝试这段代码时
let moreAnimals: [Info] = self.currentData[0..<5] //above error disply.
Run Code Online (Sandbox Code Playgroud)