objective-c

Objective-C++ 11 - Why can't we assign a block to a lambda?

和自甴很熟 提交于 2021-02-06 02:00:38
问题 So, I just upgraded to Xcode 4.4, and I noticed in the changelog: Apple LLVM compiler supports additional C++11 features, including lambdas Which is awesome! So I got around to coding, and I found a few things out: Lambdas are assignable to Objective-C blocks: void (^block)() = []() -> void { NSLog(@"Inside Lambda called as block!"); }; block(); std::function can hold an Objective-C block: std::function<void(void)> func = ^{ NSLog(@"Block inside std::function"); }; func(); We cant assign an

How can I stream audio from the microphone of an iPhone to a Mac/PC via sockets or a framework?

余生长醉 提交于 2021-02-05 20:34:15
问题 How can I stream audio from the microphone of an iPhone to a Mac/PC? Is there already some framework for this, or can I just send audio over sockets. I'm new to sockets though. Basically, I want to be able to speak into the iPhone, and the computer will receive the iPhone's mic input as its own mic input for computers that do not have microphones. I already have an app that makes a bonjour connection to a Mac, which runs a very simple server, and the iPhone can send text to the computer, but

Reading or Converting word .doc files iOS

筅森魡賤 提交于 2021-02-05 20:29:23
问题 How are other apps on iOS able to read and write word docs? I see some other questions related to this and accepted answers are along the lines of "it can't be done." I don't want to just display a word doc, I want to read it along with its formatting. How are other apps doing it, are they writing the parsing themselves using the published standard put out by Microsoft? Are they using some kind of bundled utility to convert the file to some other format like XML or HTML before processing it?

How do I provide a default implementation for an Objective-C protocol?

笑着哭i 提交于 2021-02-05 20:21:44
问题 I'd like to specify an Objective-C protocol with an optional routine. When the routine is not implemented by a class conforming to the protocol I'd like to use a default implementation in its place. Is there a place in the protocol itself where I can define this default implementation? If not, what is the best practice to reduce copying and pasting this default implementation all over the place? 回答1: Objective-C protocols have no affordance for default implementations. They are purely

why string, array and dictionary in Swift changed to value type

偶尔善良 提交于 2021-02-05 20:19:35
问题 In Objc string, array and dictionary are all reference types, while in Swift they are all value types. I want to figure out what's the reason behind the scenes, for my understanding, no matter it is a reference type or value type, the objects live in the heap in both Objc and Swift. Was the change for making coding easier? i.e. if it is reference type then the pointer to the object might not be nil, so need to check both pointer and the object not nil for accessing the object. While if it is

Firebase persistence, clear Firebase cache

旧城冷巷雨未停 提交于 2021-02-05 17:55:39
问题 My app uses Firebase to sync and restore data. I use the setValue:withCompletionBlock: method to insert, update and delete Firebase objects. This method is called whenever there is a CoreData save, thus syncing all my local changes to Firebase - (void) setValue:(id)value withCompletionBlock:(void (^)(NSError* error, Firebase* ref))block; Now syncing uploads all the local data to firebase, while restore replaces the local data with firebase data. - (void) observeSingleEventOfType:(FEventType

Buffer size for AVPlayer / AVPlayerItem

耗尽温柔 提交于 2021-02-05 13:11:36
问题 I'm creating a streaming radio application for iOS and I would like to tweak the properties of AVPlayer and AVPlayerItem to give me more reliable playback in lossy connectivity conditions. I would like to increase the buffersize. The only answer I could find is here Is there anyway to achieve this without going to OpenAL? 回答1: Add the below piece of code in your observer method. NSArray *timeRanges = (NSArray *)[change objectForKey:NSKeyValueChangeNewKey]; CMTimeRange timerange = [timeRanges

Buffer size for AVPlayer / AVPlayerItem

寵の児 提交于 2021-02-05 13:11:27
问题 I'm creating a streaming radio application for iOS and I would like to tweak the properties of AVPlayer and AVPlayerItem to give me more reliable playback in lossy connectivity conditions. I would like to increase the buffersize. The only answer I could find is here Is there anyway to achieve this without going to OpenAL? 回答1: Add the below piece of code in your observer method. NSArray *timeRanges = (NSArray *)[change objectForKey:NSKeyValueChangeNewKey]; CMTimeRange timerange = [timeRanges

Buffer size for AVPlayer / AVPlayerItem

那年仲夏 提交于 2021-02-05 13:10:39
问题 I'm creating a streaming radio application for iOS and I would like to tweak the properties of AVPlayer and AVPlayerItem to give me more reliable playback in lossy connectivity conditions. I would like to increase the buffersize. The only answer I could find is here Is there anyway to achieve this without going to OpenAL? 回答1: Add the below piece of code in your observer method. NSArray *timeRanges = (NSArray *)[change objectForKey:NSKeyValueChangeNewKey]; CMTimeRange timerange = [timeRanges

Buffer size for AVPlayer / AVPlayerItem

百般思念 提交于 2021-02-05 13:10:00
问题 I'm creating a streaming radio application for iOS and I would like to tweak the properties of AVPlayer and AVPlayerItem to give me more reliable playback in lossy connectivity conditions. I would like to increase the buffersize. The only answer I could find is here Is there anyway to achieve this without going to OpenAL? 回答1: Add the below piece of code in your observer method. NSArray *timeRanges = (NSArray *)[change objectForKey:NSKeyValueChangeNewKey]; CMTimeRange timerange = [timeRanges