title: Exception Reason: -[NSParagraphStyle bytes]: unrecognized selector sent to instance 0x16fe2130
body: <p>I have an iOS that crash sometimes because of "Exception Reason: -[NSParagraphStyle bytes]: unrecognized selector sent to instance 0x16fe2130".</p>
  
  <p>The Crash log looks like:</p>
  
  <pre><code>0 CoreFoundation 0x2b520477 &lt;redacted&gt; + 150
  1 libobjc.A.dylib 0x3941bc8b objc_exception_throw + 38
  2 CoreFoundation 0x2b525879 &lt;redacted&gt; + 0
  3 CoreFoundation 0x2b523797 &lt;redacted&gt; + 714
  4 CoreFoundation 0x2b455008 _CF_forwarding_prep_0 + 24
  5 CoreGraphics 0x2b7814c3 CGGradientGetFunction + 42
  6 CoreGraphics 0x2b7813ef CGContextDrawLinearGradient + 94
  7 MPK aFON 0x0018622b MPK aFON + 573995
  8 UIKit 0x2eab63f1 &lt;redacted&gt; + 400
  9 QuartzCore 0x2e48f04d &lt;redacted&gt; + 228
  10 QuartzCore 0x2e478a8b &lt;redacted&gt; + 2070
  11 QuartzCore 0x2e55bc09 &lt;redacted&gt; + 52
  12 QuartzCore 0x2e478269 &lt;redacted&gt; + 88
  13 QuartzCore 0x2e477f19 &lt;redacted&gt; + 1160
  14 QuartzCore 0x2e45c3d9 &lt;redacted&gt; + 200
  15 QuartzCore 0x2e45c09d &lt;redacted&gt; + 24
  16 QuartzCore 0x2e45ba71 &lt;redacted&gt; + 224
  17 QuartzCore 0x2e45b875 &lt;redacted&gt; + 324
  18 UIKit 0x2ea3c203 &lt;redacted&gt; + 1442
  19 CoreFoundation 0x2b4e6fbf &lt;redacted&gt; + 14
  20 CoreFoundation 0x2b4e63cf &lt;redacted&gt; + 218
  21 CoreFoundation 0x2b4e4a35 &lt;redacted&gt; + 772
  22 CoreFoundation 0x2b4323b1 CFRunLoopRunSpecific + 476
  23 CoreFoundation 0x2b4321c3 CFRunLoopRunInMode + 106
  24 GraphicsServices 0x32a19201 GSEventRunModal + 136
  25 UIKit 0x2ea9c43d UIApplicationMain + 1440
  26 MPK aFON 0x000fee3f MPK aFON + 20031
  27 libdyld.dylib 0x399a7aaf &lt;redacted&gt; + 2
  </code></pre>
  
  <p>I have the dSYM file for the app and for the "0x000fee3f" I got:</p>
  
  <pre><code>dSYM for Apps adrianmaftei$ dwarfdump --lookup 0x000fee3f app.app201.dSYM
  ----------------------------------------------------------------------
   File: app.app201.dSYM/Contents/Resources/DWARF/App (armv7)
  ----------------------------------------------------------------------
  Looking up address: 0x00000000000fee3f in .debug_info... found!
  
  0x002033a1: Compile Unit: length = 0x000093d7  version = 0x0002  abbr_offset = 0x00000000  addr_size = 0x04  (next CU at 0x0020c77c)
  
  0x002033ac: TAG_compile_unit [1] *
               AT_producer( "Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)" )
               AT_language( DW_LANG_ObjC )
               AT_name( "/Users/adrianmaftei/Documents/Work/aFON/Classes/AfonLFManager.m" )
               AT_stmt_list( 0x000611ac )
               AT_comp_dir( "/Users/adrianmaftei/Documents/Work/aFON" )
               AT_APPLE_optimized( 0x01 )
               AT_APPLE_major_runtime_vers( 0x02 )
               AT_low_pc( 0x000fec38 )
  
  0x00204b37:     TAG_subprogram [10] *
                   AT_name( "-[AfonLFManager parseColorInfo]" )
                   AT_decl_file( "/Users/adrianmaftei/Documents/Work/aFON/Classes/AfonLFManager.m" )
                   AT_decl_line( 57 )
                   AT_prototyped( 0x01 )
                   AT_APPLE_isa( 0x01 )
                   AT_accessibility( DW_ACCESS_public )
                   AT_low_pc( 0x000fed58 )
                   AT_high_pc( 0x000feee2 )
                   AT_frame_base( r7 )
                   AT_object_pointer( {0x00204b4f} )
  
  0x00204b76:         TAG_lexical_block [13] *
                       AT_ranges( 0x0000fa38
                          [0x000fed96 - 0x000feebc)
                          [0x000feec6 - 0x000feed2)
                           End )
  
  0x00204b7b:             TAG_lexical_block [13] *
                           AT_ranges( 0x0000fa50
                              [0x000fed9e - 0x000feebc)
                              [0x000feec6 - 0x000feed2)
                               End )
  
  0x00204b8f:                 TAG_lexical_block [13] *
                               AT_ranges( 0x0000fa68
                                  [0x000fedb0 - 0x000feebc)
                                  [0x000feec6 - 0x000feed2)
                                   End )
  
  0x00204b94:                     TAG_lexical_block [13] *
                                   AT_ranges( 0x0000fa80
                                      [0x000fedb8 - 0x000feebc)
                                      [0x000feec6 - 0x000feed2)
                                       End )
  
  0x00204b99:                         TAG_lexical_block [13] *
                                       AT_ranges( 0x0000fa98
                                          [0x000fedb8 - 0x000feebc)
                                          [0x000feec6 - 0x000feed2)
                                           End )
  
  0x00204ba9:                             TAG_lexical_block [13] *
                                           AT_ranges( 0x0000fab0
                                              [0x000fedb8 - 0x000feebc)
                                              [0x000feec6 - 0x000feeca)
                                               End )
  Line table dir : '/Users/adrianmaftei/Documents/Work/aFON/Classes'
  Line table file: 'AfonLFManager.m' line 64, column 0 with start address 0x00000000000fee10
  
  Looking up address: 0x00000000000fee3f in .debug_frame... found!
  
  0x0000d8f0: FDE
          length: 0x0000000c
     CIE_pointer: 0x00000000
      start_addr: 0x000fed58 -[AfonLFManager parseColorInfo]
      range_size: 0x0000018a (end_addr = 0x000feee2)
    Instructions: 0x000fed58: CFA=4294967295+4294967295
  </code></pre>
  
  <p>Do you have any ideas about how can I fix the issue?</p>
  
  <p>Update:
  The code for parseColorInfo is:</p>
  
  <pre><code>-(void)parseColorInfo{
  
  TBXML *tbxml = [TBXML tbxmlWithXMLString:xmlContent];
  if (tbxml){
      TBXMLElement *root = tbxml.rootXMLElement;
      if (root){
          for (int i=0; i&lt;8; i++){
              TBXMLElement *dp = [TBXML childElementNamed:[NSString stringWithFormat:@"color%d", i+1] parentElement:root];
              if (dp) {
                  if( i &lt; [colors count] ) {
                      UIColor *color = [colors objectAtIndex:i];
                      if( [TBXML textForElement:dp] ) {
                          color = [self colorFromHexString:[TBXML textForElement:dp]];
                          if( color )
                              [colors setObject:color atIndexedSubscript:i];
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>- (UIColor *)colorFromHexString:(NSString *)hexString {
  unsigned rgbValue = 0;
  NSScanner *scanner = [NSScanner scannerWithString:hexString];
  if( scanner ) {
      [scanner setScanLocation:1]; // bypass '#' character
      [scanner scanHexInt:&amp;rgbValue];
      return [UIColor colorWithRed:((rgbValue &amp; 0xFF0000) &gt;&gt; 16)/255.0 green:((rgbValue &amp; 0xFF00) &gt;&gt; 8)/255.0 blue:(rgbValue &amp; 0xFF)/255.0 alpha:1.0];
  }
  return nil;
  </code></pre>
  
  <p>}</p>