我正在尝试使用Xcode 6.2在我的Universal应用程序中运行Apple WatchKit目标
我可能做错了,但我无法访问方案菜单中的模拟器

任何的想法 ?
我想通过iOS BLE传输一个文件(大约1MB),每个发送时间会发送155bytes.
我写了2个iOS应用程序:
一个扮演中心角色,它将读取数据并发送到外围设备
另一个扮演外围角色,Il将从中央设备接收数据
问题是外围设备收到的数据太慢了.它每10秒只收到1个数据包.请参阅下面的日志.
我可以更快地通过iOS BLE发送文件(1MB)吗?
日志文件:
2015-01-05 16:51:46.072 BTLE Transfer[996:60b] <10020110 03>
2015-01-05 16:51:56.122 BTLE Transfer[996:60b] <10020110 03>
2015-01-05 16:52:06.173 BTLE Transfer[996:60b] <10020220 00001137 37905889 2737d632 de529d9d 3af28827 378827de 52373790 58882737 8827de52 37379058 89273788 26de0071 1add37ec 525bed27 de523737 90588827 378826de 56373790 58882737 8a279c17 1a07a069 88273788 27de5237 37905888 27378a27 dd523717 90588827 3588659b 7f0707a4 58882737 8827de52 37379058 8827f962 e9f61003>
2015-01-05 16:52:16.254 BTLE Transfer[996:60b] <10020220 00013488 23de5217 379058a8 2537ca62 f362070f 90588827 378827de 52373790 58882337 8c27de72 37379018 8a2775cd 0aee6305 68c25888 27378827 …Run Code Online (Sandbox Code Playgroud) 我想重新加载一个单元格UICollectionView.
我知道UITableView它是这样的:
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPathOfYourCell, nil] withRowAnimation:UITableViewRowAnimationNone];
Run Code Online (Sandbox Code Playgroud)
但是怎么样UICollectionView?
我从C Primer Plus中了解到,如果你想保护数组不被函数意外修改,你应该const在函数定义的标题中的指针声明之前添加修饰符.
遵循这个明智的建议,在下面的最小例子中,我试图将一个非常数二维数组array传递给函数Sum2D,其中一个参数是a pointer-to-const-int[2].
#include <stdio.h>
#define ROWS 2
#define COLS 2
int Sum2D(const int ar[][COLS], int rows); //use `const` to protect input array
int main(void)
{
int array[ROWS][COLS]={{1,2},{3,4}}; //the non-constant array
printf( "%d\n", Sum2D(array,ROWS) );
return 0;
}
int Sum2D(const int ar[][COLS], int rows)
{
int total=0;
int i,j;
for( i=0 ; i<rows ; i++ )
{
for( j=0 ; j<COLS ; j++ )
{
total+=ar[i][j];
}
}
return …Run Code Online (Sandbox Code Playgroud) 我有一个类,它是NSOperationQueue. 它允许使用块对网络请求进行排队。目前,请求是一个接一个执行的,但这种情况将来可能会改变。
这是 MyRequestsQueue 类的代码:
@interface MyRequestsQueue ()
@property(nonatomic, strong) NSOperationQueue* queue;
@end
@implementation MyRequestsQueue
-(instancetype)init
{
self = [super init];
if(!self) {
return nil;
}
self.queue = [[NSOperationQueue new] autorelease];
self.queue.maxConcurrentOperationCount = 1;
return self;
}
-(void)addRequestBlock:(void (^)())request
{
NSBlockOperation* operation = [NSBlockOperation blockOperationWithBlock:request];
[self.queue addOperation:operation];
}
@end
Run Code Online (Sandbox Code Playgroud)
一般来说,我知道如何使用 XCTest 对异步代码进行单元测试。但现在我想添加一个单元测试来MyRequestsQueue检查队列当时是否只执行一个操作。或者甚至更好 - 测试当前正在执行的操作的数量不大于maxConcurrentOperationCount。我试图观察operationCount的属性self.queue,但文档说我不应该依赖它。我怎样才能实现它?
编辑:我的测试使用以下模式:
@interface MessageRequestQueueTest : XCTestCase
@property(nonatomic, strong) MessageRequestsQueue* reuqestQueue;
@property(nonatomic, assign) NSInteger finishedRequestsCounter;
@end …Run Code Online (Sandbox Code Playgroud) 我有这个数组:
var preferiti : [ModalHomeLine!] = []
Run Code Online (Sandbox Code Playgroud)
我想检查数组是否包含相同的对象.
if the object exists {
} else {
var addPrf = ModalHomeLine(titolo: nomeLinea, link: linkNumeroLinea, immagine : immagine, numero : titoloLinea)
preferiti.append(addPrf)
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试将 iPhone 设置为心率监视器并使用标准心率服务发送信息,以便我在 PC 上运行的应用程序可以检索数据。我是 iOS 新手,但之前我已经在 Android 和 Windows 上运行过蓝牙功能。我正在关注这里的信息,但我在第一个障碍处就跌倒了......
根据文档中的指定,我首先调用
CBPeripheralManager *myPeripheralManager = [[CBPeripheralManager alloc] initWithDelegate:(id<CBPeripheralManagerDelegate>)self queue:nil options:nil];
Run Code Online (Sandbox Code Playgroud)
我还实现了 PeripheralManagerDidUpdateState 回调,但问题就在这里。这个回调永远不会运行!我等了几分钟,什么也没发生。我怀疑我错过了一个非常简单的步骤,因为我搜索了一整天,但在网上什么也没找到!谁能解释一下在代码中和用我的 iPhone 进行实际操作时要采取的明确步骤吗?在这个回调运行之前它必须有连接吗?它必须与任何东西配对吗?
这是完整的代码。一切运行良好,我没有收到任何错误。
#import "ViewController.h"
@import CoreBluetooth;
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSLog(@"App running...");
//Create the peripheral manager
CBPeripheralManager *myPeripheralManager = [[CBPeripheralManager alloc] initWithDelegate:(id<CBPeripheralManagerDelegate>)self queue:nil options:nil];
}
- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral{
int state = peripheral.state;
NSLog(@"Peripheral manager state …Run Code Online (Sandbox Code Playgroud) bluetooth objective-c ios core-bluetooth cbperipheralmanager
我有表视图控制器和我为所有单元格分配颜色,但我想分别为每一行分配颜色.我的细胞原型不是静止的如果任何人可以帮助我,我会很高兴.谢谢.(我用过swift)
import UIKit
class ThirdTableViewController: UITableViewController {
var dataPassed:String!
var kitap = [String]()
override func viewDidLoad() {
super.viewDidLoad()
switch dataPassed {
case "1":
kitap = [
"Yarat?l?? Kitab?","M?s?r'dan ç?k??","Levililer",
"Çölde say?m",
"Yasan?n tekrar?",
"Ye?u",
"Hakimler",
"Rut",
"I.Samuel",
"II.Samuel",
"I.Krallar",
"II.Krallar",
"I.Tarihler Adem'in soyu",
"II.Tarihler",
"Ezra",
"Nehemya",
"Ester",
"Eyüp",
"Özdeyi?ler",
"Vaiz",
"Ezgiler ezgisi",
"Ye?aya",
"Yeremya",
"A??tlar",
"Hezekiel",
"Daniel",
"Ho?ea",
"Yoel",
"Amos",
"Ovadya",
"Yunus Rab'den kaç?yor",
"Mika",
"Nahum",
"Habakkuk",
"Sefanya",
"Hagay",
"Zekeriya",
"Malaki"
]
case "2":
kitap = ["001 Mezmur","002 Mezmur","003 Mezmur","004 …Run Code Online (Sandbox Code Playgroud) 我想了解这段代码:
__weak LoginViewController *weakSelf = self;
NSTimer *networkTimer = [NSTimer pym_scheduledTimerWithTimeInterval:15.0 block:^{
LoginViewController *strongSelf = weakSelf;
[strongSelf timeout];
} repeats:NO];
[PYMAuthManager loginWithUsername:username password:password completionHandler:^(BOOL successful) {
if (successful) {
[networkTimer invalidate].......
Run Code Online (Sandbox Code Playgroud)
这是一个网络计时器,如果没有活动,将在15秒后超时.为什么在块中创建指针*strongSelf = weakSelf?使用[weakSelf timeout]不行吗?我明白无论何时在块中访问self我们都必须使用弱引用,为什么在这里创建另一个指针?任何帮助都会很棒,谢谢.
ios ×7
objective-c ×3
arrays ×2
swift ×2
apple-watch ×1
bluetooth ×1
c ×1
gcc-warning ×1
pointers ×1
uitableview ×1
unit-testing ×1
watchkit ×1
xcode6 ×1
xctest ×1