2012年11月23日星期五

How to install thoes under Xcode 4.5 (iOS 6)

       Recently when I need to get started with jailbreak dev, I find a guide here (Beginning Jailbroken iOS Development - Getting The Tools).
       But I get errors after step 6 to "make". Couse I'm in Xcode 4.5(iOS 6). I search for solution and finally get an Good Answer here(How to install thoes under Xcode 4.5 (iOS 6)). After all the steps, I can "make" and "make package" now! LOL~

2012年10月25日星期四

Print Method List of an iOS class


    Working with a SDK that has few public API Interface, I've to get methods inside it. So following code can help:
    int unsigned methodCount;
    Method *methods = class_copyMethodList([SDKCLASS class], &methodCount);
    for (int i = 0;i<methodCount;i++){
        NSLog(@"%@", NSStringFromSelector(method_getName(methods[i])));
    }
    And Done~

2012年8月9日星期四

Asynchronous NSURLConnection with NSOperation

     When I work on NSURLConnection with NSOperation today, I alloc a NSURLConnection like this

NSURLConnection* connection = [[NSURLConnection alloc] 
initWithRequest:urlRequest delegate:self];
And implements the delegate methods, but it seems that those
methods are not called at all. I search the problem in stackOverflow 
for some time and find a blog(here) that helps me know and solve the issue.
"If you are performing this on a background thread, the thread is 
probably exiting before the delegates can be called."
So I follow codes in that blog and modify code in my NSOperation object 
to keep the runloop form exiting is to just put it in an infinite loop:
- (void) start
{
  if (![self isCancelled])
  {
    connection_ = [[NSURLConnection alloc] initWithRequest: 
                          [NSURLRequest requestWithURL:download_.url  
                          cachePolicy:NSURLRequestReloadIgnoringLocalCacheData 
                          timeoutInterval:15] delegate:self]; 
    if (connection_ != nil)     
   { 
      [self willChangeValueForKey:@"isExecuting"]; 
      executing_ = YES; 
      [self didChangeValueForKey:@"isExecuting"]; 
    }    
    else 
    {       
      [self willChangeValueForKey:@"isExecuting"]; 
      finished_ = YES; 
      [self didChangeValueForKey:@"isExecuting"]; 
    } 
    while(!finished_) 
    { 
      [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode 
                               beforeDate:[NSDate distantFuture]]; 
    } 
  }
  else
  {
// If it's already been cancelled, mark the operation as finished.
    [self willChangeValueForKey:@"isFinished"]; 
    { 
      finished_ = YES; 
    } 
    [self didChangeValueForKey:@"isFinished"]; 
  }
}
This works well now :)



------
My new business with my wife, wholesale meddle-to-high end men's seamless underwear in the Netherlands: https://ecosharelife.com

2012年8月7日星期二

'libxml/xmlversion.h' file not found

     In Xcode 4.2 and 4.3 when facing this error, you can do following setting to fix it.
     In your build settings, for the key "Header Search Paths", add
"$(SDK_DIR)"/usr/include/libxml2




------
My new business with my wife, wholesale meddle-to-high end men's seamless underwear in the Netherlands: https://ecosharelife.com

2012年7月31日星期二

Audio queue starts failed err: hwiu 1752656245

    In my project, I use a AVPlayer to play local music and iPod Library music together with a AudioStreamer from Matt Gallagher (GitHub here).
        When running this app in iPhone 4s with iOS 5.1.1, it's all fine. While running in a 3GS with iOS 4.1, a failure comes "Audio queue starts failed err: hwiu 1752656245". I search the problem in Google, and find a note write by MATT CONEYBEARE (page here).
    It's because my AVPlayer is using the hardware so AudioStreamer fails.

    So, put the code after code following comment "// get the packet size if it is available":
// set the software codec too on the queue.
    UInt32 val = kAudioQueueHardwareCodecPolicy_PreferSoftware;
    OSStatus ignorableHardWareError = AudioQueueSetProperty(audioQueue, kAudioQueueProperty_HardwareCodecPolicy, &val, sizeOfUInt32);
    if (ignorableHardWareError)
    {
                  [self failWithErrorCode:AS_AUDIO_QUEUE_CREATION_FAILED]; 
        return;
    }
   And Problems solved.

   Thanks for Both Matt's work!


------
My new business with my wife, wholesale meddle-to-high end men's seamless underwear in the Netherlands: https://ecosharelife.com

2012年7月20日星期五

Developing Audio Work based on iOS 4.0

    To start with some conceptions about audio framework in iOS, I find Matt has done a good job to get some common thoughts about its history since iOS2.0 to iOS4.0 in this page.
    Then I write a DEMO using MPMoviePlayerController, it can do background playing and remote control as well, while it will be paused by the system when the App get into background. I fix this issue by using some flags, to determine when system pause it, after get into background it begins to play again. But as you can see you will find out that a short time of volume reducing and music paused. So I have a try of AVPlayer and make the MPMoviePlayerController as a backup solution.
     AVPlayer is a much more complicated API than MPMoviePlayerController. While MPMoviePlayerController provides status callbacks, I can only monitor AVPlayer's status with KVO. Some status I should monitor is an AVPlayerItem. I learned mostly from Apple's StitchedStreamPlayer Sample Code. It goes will when only one item is played and managed as well as background play and remote control. The best part is that it would not have the issue MPMoviePlayerController gets.
     Problems come when facing more then one item to play and manage. The App crashes in a concurrent thread which is from a NSNotificationCenter. I track and debugged the code many hours and finally make sure it's a KVO related issue. The Origin code of Apple's Sample first add item's observers and then make replaceCurrentItemWithPlayerItem, this resulting a crash when a notification for the previous item calls after that item is released. I changed the order to first make replaceCurrentItemWithPlayerItem and then add item's observers and fix the crash bug.
     The whole Project is now available in Github here(MyMusicAVPlayer).


PS:
If you want to make your App as a background playing one, see Apple's this page Technical Q&A 1668.
"You must declare that your application supports background audio execution, and assign an appropriate category to your audio session."
When you use MPMoviePlayerController, you should first "assign an appropriate category to your audio session" and then assign MPMoviePlayerController's useApplicationAudioSession to NO.


If you're making background vedio playing Matt has a good Note about what he has gone through in his App, you can check the page here “Background audio through an iOS movie player.


And as iOS 4.0 has many limits, an ideal method to get the duration of an AVPlayerItem in iOS 4.0 is:

[[playItem asset] duration], [playItem duration] is availble since 4.3.

2012年7月13日星期五

Sample iOS Calculator


https://github.com/senryxie/SimpleCalculator.iOS
Modifed from docchang/Calculator.iOS. Thanks for docchang's sharing.
Mine is a more simple but easy to use one, I write a label for displaying history statics, also a button for erasing numbers one by one.
The calculator is part of a big project I'm in charging.




------
My new business with my wife, wholesale meddle-to-high end men's seamless underwear in the Netherlands: https://ecosharelife.com

Senry's coming~

I'm new here, as an iOS and a person loving delicious food, I will write ideals, thoughts and my life here.


         -Senry