我正在定义一个NSString用作NSError中的错误域,并且正在复制ASIHttpRequest在那里做的事情.
NSString* const FPServerAPIErrorDomain = @"FPServerAPIErrorDomain";
Run Code Online (Sandbox Code Playgroud)
我把const放在它自己的.h文件// FPServerAPICoordinatorConstants.h中
#ifndef FirePlayer_FPServerAPICoordinatorConstants_h
#define FirePlayer_FPServerAPICoordinatorConstants_h
NSString* const FPServerAPIErrorDomain = @"FPServerAPIErrorDomain";
#endif
Run Code Online (Sandbox Code Playgroud)
但是当我把它包含在一个以上的时候
SomeFile.m
#import "FPServerAPICoordinatorConstants.h"
SomeOtherFile.m
#import "FPServerAPICoordinatorConstants.h"
Run Code Online (Sandbox Code Playgroud)
我收到链接器错误'重复符号'
ld: duplicate symbol _FPServerAPIErrorDomain in SomeFile.o and ....SomeOtherFile.o for architecture armv7
Run Code Online (Sandbox Code Playgroud)
所以我将const更改为#define,它运行正常.
// FPServerAPICoordinatorConstants.h
#ifndef FirePlayer_FPServerAPICoordinatorConstants_h
#define FirePlayer_FPServerAPICoordinatorConstants_h
//THIS WAS TRIGGERING link errors
//NSString* const FPServerAPIErrorDomain = @"FPServerAPIErrorDomain";
//working OK
#define FPServerAPIErrorDomain @"FPServerAPIErrorDomain"
#endif
Run Code Online (Sandbox Code Playgroud)
但有没有办法让const在全球空间不要抛出"重复的符号"?
我花了几个小时与一个可怕的Android资源预编译问题来处理样式,并且想知道是否有人可以解释导致它的原因.我修好了但不知道问题是什么.Android没有帮助说错误是在colors.xml中而不是在另一个xml中.
第1步 - 重新创建错误
Given a style
<style name="ActionBarTitleContainer">
<item name="android:id">@id/title_container</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">@dimen/title_height</item>
<item name="android:orientation">horizontal</item>
<item name="android:background">@color/title_color_light</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我复制了它,给了它新的,android:id
<item name="android:id">@id/info_container</item>
<style name="ActionBarTitleContainer">
<item name="android:id">@id/title_container</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">@dimen/title_height</item>
<item name="android:orientation">horizontal</item>
<item name="android:background">@color/title_color_light</item>
</style>
<style name="ActionBarInfoContainer">
<item name="android:id">@id/info_container</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">@dimen/info_height1</item>
<item name="android:orientation">horizontal</item>
<item name="android:background">@color/title_color_light</item>
</style>
Run Code Online (Sandbox Code Playgroud)
保存并编译表示id中的错误
<style name="ActionBarInfoContainer">
<item name="android:id">@id/info_container</item>
Description Resource Path Location Type
error: Error: No resource found that matches the given name (at 'android:id' with value '@id/info_container'). styles.xml /MyApp/res/values line 68 Android AAPT …Run Code Online (Sandbox Code Playgroud) 我们编写了一个媒体应用程序,允许您使用BACKGROUND FETCH获取最新视频列表作为json列表
然后它使用BACKGROUND TRANSFER告诉iOS逐个下载视频并返回睡眠状态并在应用完成后唤醒应用程序.
它完成了所有这些,但我们注意到空间使用正在增长和增长.
我们添加了代码来清除所有下载的视频,但空间使用情况在设置中保持高
我们使用Xcode> Organizer> Devices下载了app文件夹,发现BACKGROUND TRANSFER tmp文件夹对tmp文件很无聊.
这些不应该被清除掉
这通常是我使用的代码.我认为主要是我将多个DownloadTask(最多30个)附加到一个后台会话.文件大小从电影到pdf不等.
NSURLSession * backgroundSession_ = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:identifier];
backgroundSession_ = [NSURLSession sessionWithConfiguration:urlSessionConfigurationBACKGROUND_
delegate:self
delegateQueue:[NSOperationQueue mainQueue]];
NSOperationQueue *mainQueue_ = [NSOperationQueue mainQueue];
NSURLSessionDownloadTask * downloadTask_ = [backgroundSession_ downloadTaskWithURL:url_];
downloadStarted_ = TRUE;
[downloadTask_ resume];
Run Code Online (Sandbox Code Playgroud)

我有一个包含数据的CSV文件.我想将它加载到Core Data托管的sqlite db中.
我刚刚运行了一个示例Core Data Xcode应用程序并注意到它创建了db文件.我注意到表名都是以Z开头的,主键存放在单独的表中,所以我正确地假设只使用sqlite3命令行将CSV数据直接导入数据库可能会弄乱主键.
我是否需要编写一个程序来逐行读取CSV,然后为每一行创建对象并将它们保存到数据库中.有人有任何代码吗?我可以使用Core Data编写桌面客户端来执行此操作.如果是这样,db可以在IPhone核心数据应用程序中使用吗?
然后我可以在我的项目中包含预先填充的数据库,它将与应用程序正确部署,或者我还应该做些什么.
我将Safari中的Objective-C示例剪切并粘贴到Xcode中,但格式化却搞砸了.我知道我可以为{和\ r进行多次查找和替换,但是有一个按钮可以修复吗?Xcode选项/插件.TextEdit插件等?
答:我在TextWrangler中创建了一个AppleScript
tell application "TextWrangler"
activate
replace "- (" using "\\r- (" searching in text 1 of text document "untitled text" options {search mode:literal, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
select find window
select text 1 of find window
replace ";" using ";\\r" searching in text 1 of text document "untitled text" options {search mode:literal, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
select find window
replace "{" using …Run Code Online (Sandbox Code Playgroud) 当我在Interface Builder中移动控件并传递UIView时.无论如何都要阻止IB将控件嵌入到UIView中并使其成为树层次结构中UIView的子级.
BEFORE
+UIView
+UIButton
+UIView
Run Code Online (Sandbox Code Playgroud)
如果我用鼠标移动UIButton并将其置于UIView IB上方将使其成为UIView的孩子
AFTER
+UIView
+UIButton
+UIView
Run Code Online (Sandbox Code Playgroud)
无论如何都要锁定底部视图.我经常用它们作为背景并对它们进行着色.
任何人都知道iOS库或样本用于绘制图表,如思维导图/ visio/graphing sw.不必是完整的库或完整的例子.可以是UIKit或OpenGLES
我希望有一个类似于树结构的应用程序,根主题是子主题等.单击root将打开子文件夹,依此类推,它们会被布局,所以它们不会超过一圈.
我在Safari上,所以如果你知道一本带有例子的书,我也应该能找到它.
干杯
我已经获得了ac api和最低限度的文档.开发人员目前不在,他的代码返回了意外的值(数组不是预期的长度)
我有返回指向数组指针的方法的问题,并想知道我是否正确迭代它们.
问:以下是否始终返回数组的正确len?
int len=sizeof(sampleState)/sizeof(short);
int len=sizeof(samplePosition)/sizeof(int);
typedef unsigned char byte;
int len=sizeof(volume)/sizeof(byte);
Run Code Online (Sandbox Code Playgroud)
我使用指针和指针算法迭代数组(我正在为下面的所有类型正确地做)
以下最后一个例子是多维数组?什么是迭代这个的最好方法?
谢谢
//property sampleState returns short[] as short*
short* sampleState = mixerState->sampleState;
if(sampleState != NULL){
int len=sizeof(sampleState)/sizeof(short);
printf("length of short* sampleState=%d\n", len);//OK
for(int j=0;j<len;j++) {
printf(" sampleState[%d]=%u\n",j, *(sampleState+j));
}
}else{
printf(" sampleState is NULL\n");
}
//same with int[] returned as int*
int* samplePosition = mixerState->samplePosition;
if(samplePosition != NULL){
int len=sizeof(samplePosition)/sizeof(int);
printf("length of int* samplePosition=%d\n", len);//OK
for(int j=0;j<len;j++) {
printf(" samplePosition[%d]=%d\n",j, *(samplePosition+j));
}
}else{
printf(" samplePosition …Run Code Online (Sandbox Code Playgroud) 我使用 iOS Background FETCH n Background TRANSFER 来更新我们的应用程序。
当我们下载 MP4 作为大量文件的大量下载的一部分时,下载可能会突然停止并出现错误:
'客户端在收到整个响应之前关闭连接'
http代码还是200。
由于公司蜂窝帐户,我们对数据没有限制,并且我们的 iPad 上有单个应用程序,因此管理层希望我们在 20/30 的某个时候在全新安装时下载大量数据和文件数量。它们是每天发布的企业视频/pdf。
我创建了一个 NSURLSession
NSURLSession * backgroundSession_ = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:identifier]
Run Code Online (Sandbox Code Playgroud)
然后对于每个指向 mp4 或 PDF 的 URL,我从我的 NSURLSession 创建一个 NSURLSessionDownloadTask
NSURLSessionDownloadTask * downloadTask_ = [backgroundSession_ downloadTaskWithURL:url_];
Run Code Online (Sandbox Code Playgroud)
每个下载任务上的火关闭恢复。当所有返回 NSURLSession 完成时,我会在通知中告诉用户应用程序已更新。
我在我的 mac 上使用 CHARLES PROXY 来监控下载。这需要一段时间,因为有很多文件,而且我注意到电影似乎在流式传输,因此速度可能很慢。通常它会检查已下载的内容,并且只下载最新的内容,但是如果我进行了大量下载,说要进行全新安装,我注意到安静的 mp4 流经常被杀死。他们有一个 200 代码但有消息
'客户端在收到整个响应之前关闭连接'
知道什么可能导致这种情况,因为它可以阻止我的 NSURLSession 完成,因此我的同步可以进入某种挂起状态。
图像:OK 下载:电影流并保存到磁盘:200:完成

图片:下载突然停止:

任何想法:我使用后台提取所以不确定消息中的客户端是 iOS8 还是我的应用程序。每个下载任务返回后,我将 tmp 文件复制到文档中的 mp4 并调用
[session finishTasksAndInvalidate];
Run Code Online (Sandbox Code Playgroud)
如果其中一些下载任务失败,那么我注意到会话永远不会完成并卡住。当我再次获取时,我会得到所有这些旧的下载任务和旧的会话。
我正在尝试将我的应用的初始方向设置为UIInterfaceOrientationLandscapeLeft
我不能
'Initial interface orientation'[UIInterfaceOrientation]
Run Code Online (Sandbox Code Playgroud)
覆盖数组中的第一项
'Supported interface orientations'[UISupportedInterfaceOrientations]
Run Code Online (Sandbox Code Playgroud)
我注意到一个iphone应用总是以'Portrait(底部主页按钮)'开头.数组是:
'Supported interface orientations'[UISupportedInterfaceOrientations]
Portrait (bottom home button)
Landscape (left home button)
Landscape (right home button)
Run Code Online (Sandbox Code Playgroud)
这是预期的.
如果我在摘要页面上关闭PORTRAIT HOME BOTTOM按钮OFF THEN BACK ON然后数组的顺序改变而Portrait(底部主页按钮)移动到底部.
Landscape (left home button)
Landscape (right home button)
Portrait (bottom home button)
Run Code Online (Sandbox Code Playgroud)
当我运行应用程序时,它现在从横向(左主页按钮)开始,因为它现在是列表的顶部.哪个好
但
当我添加
'Initial interface orientation'[UIInterfaceOrientation]
Run Code Online (Sandbox Code Playgroud)
并将其设置为
Landscape (right home button)
Run Code Online (Sandbox Code Playgroud)
它被忽略,而数组中的第一项则被使用
Landscape (left home button)
Run Code Online (Sandbox Code Playgroud)
我检查了shouldAutorotateToInterfaceOrientation,它只阻止了肖像颠倒
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != …Run Code Online (Sandbox Code Playgroud) 如何在控制台窗口中打印出UITables indexPath.row.我不想在任何地方添加NSLog.
我一直在'不是会员'或财产.
(lldb) expr (int) printf("%d \n",self.lastChangedIndexPath->_row)
error: 'NSIndexPath' does not have a member named '_row'
(lldb) print self.lastChangedIndexPath->_row
error: 'NSIndexPath' does not have a member named '_row'
(lldb) print self.lastChangedIndexPath->row
error: 'NSIndexPath' does not have a member named 'row'
(lldb) print self.lastChangedIndexPath.row
error: property 'row' not found on object of type 'NSIndexPath *'
(lldb) po self.lastChangedIndexPath.row
error: property 'row' not found on object of type 'NSIndexPath *'
Run Code Online (Sandbox Code Playgroud)
我认为因为行和部分属于UITableView类别:
@interface NSIndexPath (UITableView)
+ (NSIndexPath *)indexPathForRow:(NSInteger)row inSection:(NSInteger)section;
@property(nonatomic,readonly) NSInteger section; …Run Code Online (Sandbox Code Playgroud) 我正在尝试将简单的GMSPlacePicker示例转换为Swift
但是Picker出现但是一旦从Right到Left的转换完成就会立即消失.
// ViewController.swift
import UIKit
import CoreLocation
import GoogleMaps
class ViewController: UIViewController {
@IBAction func buttonPlacesPicker_TouchUpInside(sender: AnyObject) {
//-----------------------------------------------------------------------------------
var southWestSydney : CLLocationCoordinate2D = CLLocationCoordinate2DMake(-33.8659, 151.1953)
var northEastSydney : CLLocationCoordinate2D = CLLocationCoordinate2DMake(-33.8645, 151.1969)
var sydneyBounds : GMSCoordinateBounds = GMSCoordinateBounds(coordinate: southWestSydney, coordinate:northEastSydney)
//var config : GMSPlacePickerConfig = GMSPlacePickerConfig(viewport:sydneyBounds)
var config : GMSPlacePickerConfig = GMSPlacePickerConfig(viewport:nil)
//---------------------------------------------------------------------
var placePicker : GMSPlacePicker = GMSPlacePicker(config: config)
//typealias GMSPlaceResultCallback = (GMSPlace?, NSError?) -> Void
var error: NSError? = nil
var gmsPlace: GMSPlace? = nil
placePicker.pickPlaceWithCallback(){ …Run Code Online (Sandbox Code Playgroud) 我的新老板认为您可以向app Store提交更新,并将其标记为一年一次或两次优先级.如果你滥用它你会失去你的特权?
他是对的.我多年来一直在提交更新,从未听说过它?
干杯